Skip to content

Commit 807103a

Browse files
authored
Merge pull request #6766 from number213/nrp-code-generation
Updated generated code for Network
2 parents 37de9fe + 4c0c84f commit 807103a

File tree

64 files changed

+4428
-1748
lines changed

Some content is hidden

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

64 files changed

+4428
-1748
lines changed

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.Netcore.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
<None Update="ScenarioTests\Data\*.*">
5454
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
5555
</None>
56+
<None Update="ScenarioTests\Generated\*.*">
57+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
58+
</None>
5659
<None Update="TestData\*.json">
5760
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
5861
</None>

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,16 @@
178178
<Compile Include="ScenarioTests\ApplicationSecurityGroupTests.cs" />
179179
<Compile Include="ScenarioTests\AvailableEndpointServicesTests.cs" />
180180
<Compile Include="ScenarioTests\ExpressRouteCrossConnectionTests.cs" />
181+
<Compile Include="ScenarioTests\Generated\ApplicationSecurityGroupTestsGenerated.cs" />
182+
<Compile Include="ScenarioTests\Generated\UsageTestsGenerated.cs" />
181183
<Compile Include="ScenarioTests\MultiIpConfigOnNicTests.cs" />
182184
<Compile Include="ScenarioTests\ExpressRouteServiceProviderTests.cs" />
183185
<Compile Include="ScenarioTests\NetworkInterfaceTests.cs" />
184186
<Compile Include="ScenarioTests\LoadBalancerTests.cs" />
185187
<Compile Include="ScenarioTests\ExpressRouteCircuitTests.cs" />
186188
<Compile Include="ScenarioTests\RouteTableTests.cs" />
187189
<Compile Include="ScenarioTests\NetworkSecurityGroupTests.cs" />
188-
<Compile Include="ScenarioTests\RouteTableTestsGenerated.cs" />
190+
<Compile Include="ScenarioTests\Generated\RouteTableTestsGenerated.cs" />
189191
<Compile Include="ScenarioTests\TestDnsAvailabilityTest.cs" />
190192
<Compile Include="ScenarioTests\UsageTests.cs" />
191193
<Compile Include="ScenarioTests\VirtualNetworkTests.cs" />
@@ -235,11 +237,17 @@
235237
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
236238
</None>
237239
<None Include="ScenarioTests\ExpressRouteCrossConnectionTests.ps1">
238-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
240+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
239241
</None>
240242
<None Include="ScenarioTests\ExpressRouteServiceProviderTests.ps1">
241243
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
242244
</None>
245+
<None Include="ScenarioTests\Generated\ApplicationSecurityGroupTestsGenerated.ps1">
246+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
247+
</None>
248+
<None Include="ScenarioTests\Generated\UsageTestsGenerated.ps1">
249+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
250+
</None>
243251
<None Include="ScenarioTests\MultiIpConfigOnNicTests.ps1">
244252
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
245253
</None>
@@ -258,7 +266,7 @@
258266
<None Include="ScenarioTests\NetworkSecurityGroupTests.ps1">
259267
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
260268
</None>
261-
<None Include="ScenarioTests\RouteTableTestsGenerated.ps1">
269+
<None Include="ScenarioTests\Generated\RouteTableTestsGenerated.ps1">
262270
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
263271
</None>
264272
<None Include="ScenarioTests\TestDnsAvailabilityTest.ps1">
@@ -297,6 +305,12 @@
297305
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.ApplicationGatewayTests\TestAvailableWafRuleSets.json">
298306
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
299307
</None>
308+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.ApplicationSecurityGroupTestsGenerated\TestApplicationSecurityGroupCRUDAllParameters.json">
309+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
310+
</None>
311+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.ApplicationSecurityGroupTestsGenerated\TestApplicationSecurityGroupCRUDMinimalParameters.json">
312+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
313+
</None>
300314
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.ApplicationSecurityGroupTests\TestApplicationSecurityGroupCollections.json">
301315
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
302316
</None>
@@ -562,6 +576,9 @@
562576
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.TestDnsAvailabilityTest\TestDnsAvailability.json">
563577
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
564578
</None>
579+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.UsageTestsGenerated\TestUsageCRUDMinimalParameters.json">
580+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
581+
</None>
565582
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.VirtualNetworkGatewayConnectionTests\TestVirtualNetworkeExpressRouteGatewayConnectionCRUD.json">
566583
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
567584
</None>

src/ResourceManager/Network/Commands.Network.Test/NetworkResourcesController.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,34 @@ public void RunPsTestWorkflow(
9393

9494
_helper.SetupEnvironment(AzureModule.AzureResourceManager);
9595

96-
var callingClassName = callingClassType
96+
var callingClassName = callingClassType
9797
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
9898
.Last();
99+
100+
string scenarioTestsDir = Path.Combine(Directory.GetCurrentDirectory(), "ScenarioTests");
101+
string psScriptPath = null;
102+
103+
var testDirs = Directory.GetDirectories(scenarioTestsDir).ToList();
104+
testDirs.Insert(0, scenarioTestsDir);
105+
106+
foreach (var dir in testDirs)
107+
{
108+
var testPath = Path.Combine(dir, callingClassName + ".ps1");
109+
if (File.Exists(testPath))
110+
{
111+
psScriptPath = testPath;
112+
break;
113+
}
114+
}
115+
116+
if (psScriptPath == null)
117+
{
118+
throw new FileNotFoundException(string.Format("Couldn't find ps1 file for test class '{0}'", callingClassName));
119+
}
120+
99121
_helper.SetupModules(AzureModule.AzureResourceManager,
100122
"ScenarioTests\\Common.ps1",
101-
"ScenarioTests\\" + callingClassName + ".ps1",
123+
psScriptPath,
102124
_helper.RMProfileModule,
103125
_helper.RMResourceModule,
104126
_helper.GetRMModulePath("AzureRM.Insights.psd1"),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// <auto-generated>
2+
// Copyright (c) Microsoft and contributors. All rights reserved.
3+
//
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+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
//
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
//
17+
// Warning: This code was generated by a tool.
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if the
20+
// code is regenerated.
21+
//
22+
// For documentation on code generator please visit
23+
// https://aka.ms/nrp-code-generation
24+
// Please contact [email protected] if you need to make changes to this file.
25+
// </auto-generated>
26+
27+
using System;
28+
using Microsoft.Azure.ServiceManagemenet.Common.Models;
29+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
30+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
31+
using Xunit;
32+
using Xunit.Abstractions;
33+
34+
namespace Commands.Network.Test.ScenarioTests
35+
{
36+
public class ApplicationSecurityGroupTestsGenerated : RMTestBase
37+
{
38+
public XunitTracingInterceptor _logger;
39+
40+
public ApplicationSecurityGroupTestsGenerated(Xunit.Abstractions.ITestOutputHelper output)
41+
{
42+
_logger = new XunitTracingInterceptor(output);
43+
XunitTracingInterceptor.AddToContext(_logger);
44+
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
[Trait(Category.Owner, Category.wanrpdev)]
49+
public void TestApplicationSecurityGroupCRUDMinimalParameters()
50+
{
51+
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-ApplicationSecurityGroupCRUDMinimalParameters"));
52+
}
53+
54+
[Fact]
55+
[Trait(Category.AcceptanceType, Category.CheckIn)]
56+
[Trait(Category.Owner, Category.wanrpdev)]
57+
public void TestApplicationSecurityGroupCRUDAllParameters()
58+
{
59+
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-ApplicationSecurityGroupCRUDAllParameters"));
60+
}
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# <auto-generated>
2+
# Copyright (c) Microsoft and contributors. All rights reserved.
3+
#
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+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
#
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
#
17+
# Warning: This code was generated by a tool.
18+
#
19+
# Changes to this file may cause incorrect behavior and will be lost if the
20+
# code is regenerated.
21+
#
22+
# For documentation on code generator please visit
23+
# https://aka.ms/nrp-code-generation
24+
# Please contact [email protected] if you need to make changes to this file.
25+
# </auto-generated>
26+
27+
function Check-CmdletReturnType
28+
{
29+
param($cmdletName, $cmdletReturn)
30+
31+
$cmdletData = Get-Command $cmdletName;
32+
Assert-NotNull $cmdletData;
33+
[array]$cmdletReturnTypes = $cmdletData.OutputType.Name | Foreach-Object { return ($_ -replace "Microsoft.Azure.Commands.Network.Models.","") };
34+
[array]$cmdletReturnTypes = $cmdletReturnTypes | Foreach-Object { return ($_ -replace "System.","") };
35+
$realReturnType = $cmdletReturn.GetType().Name -replace "Microsoft.Azure.Commands.Network.Models.","";
36+
return $cmdletReturnTypes -contains $realReturnType;
37+
}
38+
39+
<#
40+
.SYNOPSIS
41+
Test creating new ApplicationSecurityGroup using minimal set of parameters
42+
#>
43+
function Test-ApplicationSecurityGroupCRUDMinimalParameters
44+
{
45+
# Setup
46+
$rgname = Get-ResourceGroupName;
47+
$rglocation = Get-ProviderLocation ResourceManagement;
48+
$rname = Get-ResourceName;
49+
$location = Get-ProviderLocation "Microsoft.Network/ApplicationSecurityGroups";
50+
51+
try
52+
{
53+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation;
54+
55+
# Create ApplicationSecurityGroup
56+
$vApplicationSecurityGroup = New-AzureRmApplicationSecurityGroup -ResourceGroupName $rgname -Name $rname -Location $location;
57+
Assert-NotNull $vApplicationSecurityGroup;
58+
Assert-True { Check-CmdletReturnType "New-AzureRmApplicationSecurityGroup" $vApplicationSecurityGroup };
59+
Assert-AreEqual $rname $vApplicationSecurityGroup.Name;
60+
61+
# Get ApplicationSecurityGroup
62+
$vApplicationSecurityGroup = Get-AzureRmApplicationSecurityGroup -ResourceGroupName $rgname -Name $rname;
63+
Assert-NotNull $vApplicationSecurityGroup;
64+
Assert-True { Check-CmdletReturnType "Get-AzureRmApplicationSecurityGroup" $vApplicationSecurityGroup };
65+
Assert-AreEqual $rname $vApplicationSecurityGroup.Name;
66+
67+
# Remove ApplicationSecurityGroup
68+
$removeApplicationSecurityGroup = Remove-AzureRmApplicationSecurityGroup -ResourceGroupName $rgname -Name $rname -PassThru -Force;
69+
Assert-AreEqual $true $removeApplicationSecurityGroup;
70+
71+
# Get ApplicationSecurityGroup should fail
72+
Assert-ThrowsContains { Get-AzureRmApplicationSecurityGroup -ResourceGroupName $rgname -Name $rname } "${rname} not found";
73+
}
74+
finally
75+
{
76+
# Cleanup
77+
Clean-ResourceGroup $rgname;
78+
}
79+
}
80+
81+
<#
82+
.SYNOPSIS
83+
Test creating new ApplicationSecurityGroup
84+
#>
85+
function Test-ApplicationSecurityGroupCRUDAllParameters
86+
{
87+
# Setup
88+
$rgname = Get-ResourceGroupName;
89+
$rglocation = Get-ProviderLocation ResourceManagement;
90+
$rname = Get-ResourceName;
91+
$location = Get-ProviderLocation "Microsoft.Network/ApplicationSecurityGroups";
92+
# Resource's parameters
93+
$Tag = @{tag1='test'};
94+
95+
try
96+
{
97+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation;
98+
99+
# Create ApplicationSecurityGroup
100+
$vApplicationSecurityGroup = New-AzureRmApplicationSecurityGroup -ResourceGroupName $rgname -Name $rname -Location $location -Tag $Tag;
101+
Assert-NotNull $vApplicationSecurityGroup;
102+
Assert-True { Check-CmdletReturnType "New-AzureRmApplicationSecurityGroup" $vApplicationSecurityGroup };
103+
Assert-AreEqual $rname $vApplicationSecurityGroup.Name;
104+
Assert-AreEqualObjectProperties $Tag $vApplicationSecurityGroup.Tag;
105+
106+
# Get ApplicationSecurityGroup
107+
$vApplicationSecurityGroup = Get-AzureRmApplicationSecurityGroup -ResourceGroupName $rgname -Name $rname;
108+
Assert-NotNull $vApplicationSecurityGroup;
109+
Assert-True { Check-CmdletReturnType "Get-AzureRmApplicationSecurityGroup" $vApplicationSecurityGroup };
110+
Assert-AreEqual $rname $vApplicationSecurityGroup.Name;
111+
Assert-AreEqualObjectProperties $Tag $vApplicationSecurityGroup.Tag;
112+
113+
# Remove ApplicationSecurityGroup
114+
$removeApplicationSecurityGroup = Remove-AzureRmApplicationSecurityGroup -ResourceGroupName $rgname -Name $rname -PassThru -Force;
115+
Assert-AreEqual $true $removeApplicationSecurityGroup;
116+
117+
# Get ApplicationSecurityGroup should fail
118+
Assert-ThrowsContains { Get-AzureRmApplicationSecurityGroup -ResourceGroupName $rgname -Name $rname } "${rname} not found";
119+
}
120+
finally
121+
{
122+
# Cleanup
123+
Clean-ResourceGroup $rgname;
124+
}
125+
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1-
// ----------------------------------------------------------------------------------
2-
//
3-
// Copyright Microsoft Corporation
1+
// <auto-generated>
2+
// Copyright (c) Microsoft and contributors. All rights reserved.
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
89
// Unless required by applicable law or agreed to in writing, software
910
// distributed under the License is distributed on an "AS IS" BASIS,
1011
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
//
1113
// See the License for the specific language governing permissions and
1214
// limitations under the License.
13-
// ----------------------------------------------------------------------------------
15+
//
16+
//
17+
// Warning: This code was generated by a tool.
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if the
20+
// code is regenerated.
21+
//
22+
// For documentation on code generator please visit
23+
// https://aka.ms/nrp-code-generation
24+
// Please contact [email protected] if you need to make changes to this file.
25+
// </auto-generated>
1426

1527
using System;
1628
using Microsoft.Azure.ServiceManagemenet.Common.Models;
@@ -31,37 +43,36 @@ public RouteTableTestsGenerated(Xunit.Abstractions.ITestOutputHelper output)
3143
XunitTracingInterceptor.AddToContext(_logger);
3244
}
3345

34-
3546
[Fact]
3647
[Trait(Category.AcceptanceType, Category.CheckIn)]
3748
[Trait(Category.Owner, Category.wanrpdev)]
38-
public void TestRouteCRUDMinimalParameters()
49+
public void TestRouteTableCRUDMinimalParameters()
3950
{
40-
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-RouteCRUDMinimalParameters"));
51+
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-RouteTableCRUDMinimalParameters"));
4152
}
4253

4354
[Fact]
4455
[Trait(Category.AcceptanceType, Category.CheckIn)]
4556
[Trait(Category.Owner, Category.wanrpdev)]
46-
public void TestRouteCRUDAllParameters()
57+
public void TestRouteTableCRUDAllParameters()
4758
{
48-
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-RouteCRUDAllParameters"));
59+
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-RouteTableCRUDAllParameters"));
4960
}
5061

5162
[Fact]
5263
[Trait(Category.AcceptanceType, Category.CheckIn)]
5364
[Trait(Category.Owner, Category.wanrpdev)]
54-
public void TestRouteTableCRUDMinimalParameters()
65+
public void TestRouteCRUDMinimalParameters()
5566
{
56-
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-RouteTableCRUDMinimalParameters"));
67+
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-RouteCRUDMinimalParameters"));
5768
}
5869

5970
[Fact]
6071
[Trait(Category.AcceptanceType, Category.CheckIn)]
6172
[Trait(Category.Owner, Category.wanrpdev)]
62-
public void TestRouteTableCRUDAllParameters()
73+
public void TestRouteCRUDAllParameters()
6374
{
64-
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-RouteTableCRUDAllParameters"));
75+
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-RouteCRUDAllParameters"));
6576
}
6677
}
6778
}

0 commit comments

Comments
 (0)