Skip to content

Commit 2e92b6d

Browse files
committed
Sql2: Adding cmdlets for:
- Server CRUD - Database CRUD - Server Firewall Rule CRUD - Added powershell attribute tests.
1 parent 475ebc2 commit 2e92b6d

File tree

57 files changed

+2620
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2620
-106
lines changed

src/Common/Commands.ScenarioTests.Common/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class Category
3838

3939
public const string Store = "Store";
4040

41+
public const string Sql = "Sql";
42+
4143
public const string ServiceManagement = "ServiceManagement";
4244

4345
public const string Resources = "Resources";

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@
147147
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
148148
<Compile Include="ScenarioTests\SecurityTests.cs" />
149149
<Compile Include="ScenarioTests\SqlTestsBase.cs" />
150+
<Compile Include="UnitTests\AzureSqlCmdletBaseAttributeTests.cs" />
151+
<Compile Include="UnitTests\AzureSqlDatabaseAttributeTests.cs" />
152+
<Compile Include="UnitTests\AzureSqlDatabaseServerFirewallRuleAttributeTests.cs" />
153+
<Compile Include="UnitTests\AzureSqlDatabaseServerAttributeTests.cs" />
154+
<Compile Include="Utilities\UnitTestHelper.cs" />
150155
</ItemGroup>
151156
<ItemGroup>
152157
<ProjectReference Include="..\..\..\Common\Commands.ScenarioTests.Common\Commands.ScenarioTests.Common.csproj">
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Sql.Common;
16+
using Microsoft.Azure.Commands.Sql.Test.Utilities;
17+
using Xunit;
18+
19+
namespace Microsoft.Azure.Commands.Sql.Test.UnitTests
20+
{
21+
public class AzureSqlCmdletBaseAttributeTests
22+
{
23+
[Fact]
24+
public void TestAzureSqlCmdletBaseAttributes()
25+
{
26+
UnitTestHelper.CheckCmdletParameterAttributes(typeof(AzureSqlCmdletBase<object, object>), "ResourceGroupName", true, true);
27+
}
28+
29+
[Fact]
30+
public void TestAzureSqlDatabaseCmdletBaseAttributes()
31+
{
32+
UnitTestHelper.CheckCmdletParameterAttributes(typeof(AzureSqlDatabaseCmdletBase<object, object>), "DatabaseName", true, true);
33+
UnitTestHelper.CheckCmdletParameterAttributes(typeof(AzureSqlDatabaseCmdletBase<object, object>), "ServerName", true, true);
34+
}
35+
}
36+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using Microsoft.Azure.Commands.Sql.Database.Cmdlet;
17+
using Microsoft.Azure.Commands.Sql.Test.Utilities;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Xunit;
20+
21+
namespace Microsoft.Azure.Commands.Sql.Test.UnitTests
22+
{
23+
public class AzureSqlDatabaseAttributeTests
24+
{
25+
[Fact]
26+
[Trait(Category.Sql, Category.CheckIn)]
27+
public void NewAzureSqlDatabaseAttributes()
28+
{
29+
Type type = typeof(NewAzureSqlDatabase);
30+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false);
31+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.Medium);
32+
33+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
34+
UnitTestHelper.CheckCmdletParameterAttributes(type, "DatabaseName", isMandatory: true, valueFromPipelineByName: true);
35+
UnitTestHelper.CheckCmdletParameterAttributes(type, "CollationName", isMandatory: false, valueFromPipelineByName: true);
36+
UnitTestHelper.CheckCmdletParameterAttributes(type, "CatalogCollation", isMandatory: false, valueFromPipelineByName: true);
37+
UnitTestHelper.CheckCmdletParameterAttributes(type, "MaxSizeBytes", isMandatory: false, valueFromPipelineByName: true);
38+
UnitTestHelper.CheckCmdletParameterAttributes(type, "Edition", isMandatory: false, valueFromPipelineByName: true);
39+
UnitTestHelper.CheckCmdletParameterAttributes(type, "RequestedServiceObjectiveName", isMandatory: false, valueFromPipelineByName: true);
40+
UnitTestHelper.CheckCmdletParameterAttributes(type, "Tags", isMandatory: false, valueFromPipelineByName: true);
41+
}
42+
43+
[Fact]
44+
[Trait(Category.Sql, Category.CheckIn)]
45+
public void SetAzureSqlDatabaseAttributes()
46+
{
47+
Type type = typeof(SetAzureSqlDatabase);
48+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false);
49+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.Medium);
50+
51+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
52+
UnitTestHelper.CheckCmdletParameterAttributes(type, "DatabaseName", isMandatory: true, valueFromPipelineByName: true);
53+
UnitTestHelper.CheckCmdletParameterAttributes(type, "MaxSizeBytes", isMandatory: false, valueFromPipelineByName: true);
54+
UnitTestHelper.CheckCmdletParameterAttributes(type, "Edition", isMandatory: false, valueFromPipelineByName: true);
55+
UnitTestHelper.CheckCmdletParameterAttributes(type, "RequestedServiceObjectiveName", isMandatory: false, valueFromPipelineByName: true);
56+
UnitTestHelper.CheckCmdletParameterAttributes(type, "Tags", isMandatory: false, valueFromPipelineByName: true);
57+
}
58+
59+
[Fact]
60+
[Trait(Category.Sql, Category.CheckIn)]
61+
public void RemoveAzureSqlDatabaseAttributes()
62+
{
63+
Type type = typeof(RemoveAzureSqlDatabase);
64+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: true);
65+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.High);
66+
67+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
68+
UnitTestHelper.CheckCmdletParameterAttributes(type, "DatabaseName", isMandatory: true, valueFromPipelineByName: true);
69+
}
70+
71+
[Fact]
72+
[Trait(Category.Sql, Category.CheckIn)]
73+
public void GetAzureSqlDatabaseAttributes()
74+
{
75+
Type type = typeof(GetAzureSqlDatabase);
76+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false);
77+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.None);
78+
79+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
80+
UnitTestHelper.CheckCmdletParameterAttributes(type, "DatabaseName", isMandatory: false, valueFromPipelineByName: true);
81+
}
82+
}
83+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using Microsoft.Azure.Commands.Sql.Server.Cmdlet;
17+
using Microsoft.Azure.Commands.Sql.Test.Utilities;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Xunit;
20+
21+
namespace Microsoft.Azure.Commands.Sql.Test.UnitTests
22+
{
23+
public class AzureSqlDatabaseServerAttributeTests
24+
{
25+
[Fact]
26+
[Trait(Category.Sql, Category.CheckIn)]
27+
public void NewAzureSqlDatabaseServerAttributes()
28+
{
29+
Type type = typeof(NewAzureSqlDatabaseServer);
30+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: true);
31+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.Medium);
32+
33+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
34+
UnitTestHelper.CheckCmdletParameterAttributes(type, "SqlAdminCredentials", isMandatory: true, valueFromPipelineByName: false);
35+
UnitTestHelper.CheckCmdletParameterAttributes(type, "Tags", isMandatory: false, valueFromPipelineByName: true);
36+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerVersion", isMandatory: false, valueFromPipelineByName: true);
37+
}
38+
39+
[Fact]
40+
[Trait(Category.Sql, Category.CheckIn)]
41+
public void SetAzureSqlDatabaseServerAttributes()
42+
{
43+
Type type = typeof(SetAzureSqlDatabaseServer);
44+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: true);
45+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.Medium);
46+
47+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
48+
UnitTestHelper.CheckCmdletParameterAttributes(type, "SqlAdminPassword", isMandatory: false, valueFromPipelineByName: false);
49+
UnitTestHelper.CheckCmdletParameterAttributes(type, "Tags", isMandatory: false, valueFromPipelineByName: true);
50+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerVersion", isMandatory: false, valueFromPipelineByName: true);
51+
}
52+
53+
[Fact]
54+
[Trait(Category.Sql, Category.CheckIn)]
55+
public void RemoveAzureSqlDatabaseServerAttributes()
56+
{
57+
Type type = typeof(RemoveAzureSqlDatabaseServer);
58+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: true);
59+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.High);
60+
61+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
62+
}
63+
64+
[Fact]
65+
[Trait(Category.Sql, Category.CheckIn)]
66+
public void GetAzureSqlDatabaseServerAttributes()
67+
{
68+
Type type = typeof(GetAzureSqlDatabaseServer);
69+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false);
70+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.None);
71+
72+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: false, valueFromPipelineByName: true);
73+
}
74+
}
75+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using Microsoft.Azure.Commands.Sql.FirewallRule.Cmdlet;
17+
using Microsoft.Azure.Commands.Sql.Test.Utilities;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Xunit;
20+
21+
namespace Microsoft.Azure.Commands.Sql.Test.UnitTests
22+
{
23+
public class AzureSqlDatabaseServerFirewallRuleAttributeTests
24+
{
25+
[Fact]
26+
[Trait(Category.Sql, Category.CheckIn)]
27+
public void NewAzureSqlDatabaseServerFirewallRuleAttributes()
28+
{
29+
Type type = typeof(NewAzureSqlDatabaseServerFirewallRule);
30+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false);
31+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.Medium);
32+
33+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
34+
UnitTestHelper.CheckCmdletParameterAttributes(type, "FirewallRuleName", isMandatory: true, valueFromPipelineByName: true);
35+
UnitTestHelper.CheckCmdletParameterAttributes(type, "StartIpAddress", isMandatory: true, valueFromPipelineByName: true);
36+
UnitTestHelper.CheckCmdletParameterAttributes(type, "EndIpAddress", isMandatory: true, valueFromPipelineByName: true);
37+
}
38+
39+
[Fact]
40+
[Trait(Category.Sql, Category.CheckIn)]
41+
public void SetAzureSqlDatabaseServerFirewallRuleAttributes()
42+
{
43+
Type type = typeof(SetAzureSqlDatabaseServerFirewallRule);
44+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false);
45+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.Medium);
46+
47+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
48+
UnitTestHelper.CheckCmdletParameterAttributes(type, "FirewallRuleName", isMandatory: true, valueFromPipelineByName: true);
49+
UnitTestHelper.CheckCmdletParameterAttributes(type, "StartIpAddress", isMandatory: true, valueFromPipelineByName: true);
50+
UnitTestHelper.CheckCmdletParameterAttributes(type, "EndIpAddress", isMandatory: true, valueFromPipelineByName: true);
51+
}
52+
53+
[Fact]
54+
[Trait(Category.Sql, Category.CheckIn)]
55+
public void RemoveAzureSqlDatabaseServerFirewallRuleAttributes()
56+
{
57+
Type type = typeof(RemoveAzureSqlDatabaseServerFirewallRule);
58+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: true);
59+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.High);
60+
61+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
62+
UnitTestHelper.CheckCmdletParameterAttributes(type, "FirewallRuleName", isMandatory: true, valueFromPipelineByName: true);
63+
}
64+
65+
[Fact]
66+
[Trait(Category.Sql, Category.CheckIn)]
67+
public void GetAzureSqlDatabaseServerFirewallRuleAttributes()
68+
{
69+
Type type = typeof(GetAzureSqlDatabaseServerFirewallRule);
70+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false);
71+
UnitTestHelper.CheckConfirmImpact(type, System.Management.Automation.ConfirmImpact.None);
72+
73+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
74+
UnitTestHelper.CheckCmdletParameterAttributes(type, "FirewallRuleName", isMandatory: false, valueFromPipelineByName: true);
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)