Skip to content

Commit 96bbada

Browse files
authored
Merge pull request Azure#5505 from EvgenyAgafonchikov/rt-generated
Regenerated Route Table, added generated tests
2 parents ed7a087 + 59f2f04 commit 96bbada

16 files changed

+6000
-22
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
<Compile Include="ScenarioTests\ExpressRouteCircuitTests.cs" />
189189
<Compile Include="ScenarioTests\RouteTableTests.cs" />
190190
<Compile Include="ScenarioTests\NetworkSecurityGroupTests.cs" />
191+
<Compile Include="ScenarioTests\RouteTableTestsGenerated.cs" />
191192
<Compile Include="ScenarioTests\TestDnsAvailabilityTest.cs" />
192193
<Compile Include="ScenarioTests\UsageTests.cs" />
193194
<Compile Include="ScenarioTests\VirtualNetworkTests.cs" />
@@ -254,6 +255,9 @@
254255
<None Include="ScenarioTests\NetworkSecurityGroupTests.ps1">
255256
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
256257
</None>
258+
<None Include="ScenarioTests\RouteTableTestsGenerated.ps1">
259+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
260+
</None>
257261
<None Include="ScenarioTests\TestDnsAvailabilityTest.ps1">
258262
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
259263
</None>
@@ -500,6 +504,18 @@
500504
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.PublicIpAddressTests\TestPublicIpStandardSku.json">
501505
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
502506
</None>
507+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.RouteTableTestsGenerated\TestRouteCRUDAllParameters.json">
508+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
509+
</None>
510+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.RouteTableTestsGenerated\TestRouteCRUDMinimalParameters.json">
511+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
512+
</None>
513+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.RouteTableTestsGenerated\TestRouteTableCRUDAllParameters.json">
514+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
515+
</None>
516+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.RouteTableTestsGenerated\TestRouteTableCRUDMinimalParameters.json">
517+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
518+
</None>
503519
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.RouteTableTests\TestEmptyRouteTable.json">
504520
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
505521
</None>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.ServiceManagemenet.Common.Models;
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
19+
using Xunit;
20+
using Xunit.Abstractions;
21+
22+
namespace Commands.Network.Test.ScenarioTests
23+
{
24+
public class RouteTableTestsGenerated : RMTestBase
25+
{
26+
public RouteTableTestsGenerated(ITestOutputHelper output)
27+
{
28+
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
29+
}
30+
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void TestRouteCRUDMinimalParameters()
34+
{
35+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-RouteCRUDMinimalParameters"));
36+
}
37+
38+
[Fact]
39+
[Trait(Category.AcceptanceType, Category.CheckIn)]
40+
public void TestRouteCRUDAllParameters()
41+
{
42+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-RouteCRUDAllParameters"));
43+
}
44+
45+
[Fact]
46+
[Trait(Category.AcceptanceType, Category.CheckIn)]
47+
public void TestRouteTableCRUDMinimalParameters()
48+
{
49+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-RouteTableCRUDMinimalParameters"));
50+
}
51+
52+
[Fact]
53+
[Trait(Category.AcceptanceType, Category.CheckIn)]
54+
public void TestRouteTableCRUDAllParameters()
55+
{
56+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-RouteTableCRUDAllParameters"));
57+
}
58+
}
59+
}
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
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+
# Warning: This code was generated by a tool.
16+
#
17+
# Changes to this file may cause incorrect behavior and will be lost if the
18+
# code is regenerated.
19+
20+
<#
21+
.SYNOPSIS
22+
Test creating new Route using minimal set of parameters
23+
#>
24+
function Test-RouteCRUDMinimalParameters
25+
{
26+
# Setup
27+
$rgname = Get-ResourceGroupName;
28+
$rglocation = Get-ProviderLocation ResourceManagement;
29+
$rname = Get-ResourceName;
30+
$rnameAdd = "${rname}Add";
31+
$resourceTypeParent = "Microsoft.Network/RouteTables";
32+
$location = Get-ProviderLocation $resourceTypeParent;
33+
# Resource's parameters
34+
$AddressPrefix = "10.0.0.0/8";
35+
# Resource's parameters for Set test
36+
$AddressPrefixSet = "11.0.0.0/8";
37+
# Resource's parameters for Add test
38+
$AddressPrefixAdd = "12.0.0.0/8";
39+
40+
try
41+
{
42+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation;
43+
44+
# Create Route
45+
$vRoute = New-AzureRmRouteConfig -Name $rname -AddressPrefix $AddressPrefix;
46+
Assert-NotNull $vRoute;
47+
$vRouteTable = New-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname -Route $vRoute -Location $location;
48+
Assert-NotNull $vRouteTable;
49+
Assert-AreEqual $rname $vRoute.Name;
50+
Assert-AreEqual $AddressPrefix $vRoute.AddressPrefix;
51+
52+
# Get Route
53+
$vRoute = Get-AzureRmRouteConfig -RouteTable $vRouteTable -Name $rname;
54+
Assert-NotNull $vRoute;
55+
Assert-AreEqual $rname $vRoute.Name;
56+
Assert-AreEqual $AddressPrefix $vRoute.AddressPrefix;
57+
58+
# Set Route
59+
$vRouteTable = Set-AzureRmRouteConfig -Name $rname -RouteTable $vRouteTable -AddressPrefix $AddressPrefixSet;
60+
Assert-NotNull $vRouteTable;
61+
Set-AzureRmRouteTable -RouteTable $vRouteTable;
62+
63+
# Get Route
64+
$vRoute = Get-AzureRmRouteConfig -RouteTable $vRouteTable -Name $rname;
65+
Assert-NotNull $vRoute;
66+
Assert-AreEqual $rname $vRoute.Name;
67+
Assert-AreEqual $AddressPrefixSet $vRoute.AddressPrefix;
68+
69+
# Add Route
70+
$vRouteTable = Add-AzureRmRouteConfig -Name $rnameAdd -RouteTable $vRouteTable -AddressPrefix $AddressPrefixAdd;
71+
Assert-NotNull $vRouteTable;
72+
Set-AzureRmRouteTable -RouteTable $vRouteTable;
73+
74+
# Get Route
75+
$vRoute = Get-AzureRmRouteConfig -RouteTable $vRouteTable -Name $rnameAdd;
76+
Assert-NotNull $vRoute;
77+
Assert-AreEqual $rnameAdd $vRoute.Name;
78+
Assert-AreEqual $AddressPrefixAdd $vRoute.AddressPrefix;
79+
80+
# Remove Route
81+
Remove-AzureRmRouteConfig -RouteTable $vRouteTable -Name $vRouteTable.Routes[-1].Name;
82+
Set-AzureRmRouteTable -RouteTable $vRouteTable;
83+
}
84+
finally
85+
{
86+
# Cleanup
87+
Clean-ResourceGroup $rgname;
88+
}
89+
}
90+
91+
<#
92+
.SYNOPSIS
93+
Test creating new Route
94+
#>
95+
function Test-RouteCRUDAllParameters
96+
{
97+
# Setup
98+
$rgname = Get-ResourceGroupName;
99+
$rglocation = Get-ProviderLocation ResourceManagement;
100+
$rname = Get-ResourceName;
101+
$rnameAdd = "${rname}Add";
102+
$resourceTypeParent = "Microsoft.Network/RouteTables";
103+
$location = Get-ProviderLocation $resourceTypeParent;
104+
# Resource's parameters
105+
$AddressPrefix = "10.0.0.0/8";
106+
$NextHopType = "VirtualNetworkGateway";
107+
# Resource's parameters for Set test
108+
$AddressPrefixSet = "11.0.0.0/8";
109+
$NextHopTypeSet = "VnetLocal";
110+
# Resource's parameters for Add test
111+
$AddressPrefixAdd = "12.0.0.0/8";
112+
$NextHopTypeAdd = "VnetLocal";
113+
114+
try
115+
{
116+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation;
117+
118+
# Create Route
119+
$vRoute = New-AzureRmRouteConfig -Name $rname -AddressPrefix $AddressPrefix -NextHopType $NextHopType;
120+
Assert-NotNull $vRoute;
121+
$vRouteTable = New-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname -Route $vRoute -Location $location;
122+
Assert-NotNull $vRouteTable;
123+
Assert-AreEqual $rname $vRoute.Name;
124+
Assert-AreEqual $AddressPrefix $vRoute.AddressPrefix;
125+
Assert-AreEqual $NextHopType $vRoute.NextHopType;
126+
127+
# Get Route
128+
$vRoute = Get-AzureRmRouteConfig -RouteTable $vRouteTable -Name $rname;
129+
Assert-NotNull $vRoute;
130+
Assert-AreEqual $rname $vRoute.Name;
131+
Assert-AreEqual $AddressPrefix $vRoute.AddressPrefix;
132+
Assert-AreEqual $NextHopType $vRoute.NextHopType;
133+
134+
# Set Route
135+
$vRouteTable = Set-AzureRmRouteConfig -Name $rname -RouteTable $vRouteTable -AddressPrefix $AddressPrefixSet -NextHopType $NextHopTypeSet;
136+
Assert-NotNull $vRouteTable;
137+
Set-AzureRmRouteTable -RouteTable $vRouteTable;
138+
139+
# Get Route
140+
$vRoute = Get-AzureRmRouteConfig -RouteTable $vRouteTable -Name $rname;
141+
Assert-NotNull $vRoute;
142+
Assert-AreEqual $rname $vRoute.Name;
143+
Assert-AreEqual $AddressPrefixSet $vRoute.AddressPrefix;
144+
Assert-AreEqual $NextHopTypeSet $vRoute.NextHopType;
145+
146+
# Add Route
147+
$vRouteTable = Add-AzureRmRouteConfig -Name $rnameAdd -RouteTable $vRouteTable -AddressPrefix $AddressPrefixAdd -NextHopType $NextHopTypeAdd;
148+
Assert-NotNull $vRouteTable;
149+
Set-AzureRmRouteTable -RouteTable $vRouteTable;
150+
151+
# Get Route
152+
$vRoute = Get-AzureRmRouteConfig -RouteTable $vRouteTable -Name $rnameAdd;
153+
Assert-NotNull $vRoute;
154+
Assert-AreEqual $rnameAdd $vRoute.Name;
155+
Assert-AreEqual $AddressPrefixAdd $vRoute.AddressPrefix;
156+
Assert-AreEqual $NextHopTypeAdd $vRoute.NextHopType;
157+
158+
# Remove Route
159+
Remove-AzureRmRouteConfig -RouteTable $vRouteTable -Name $vRouteTable.Routes[-1].Name;
160+
Set-AzureRmRouteTable -RouteTable $vRouteTable;
161+
}
162+
finally
163+
{
164+
# Cleanup
165+
Clean-ResourceGroup $rgname;
166+
}
167+
}
168+
169+
<#
170+
.SYNOPSIS
171+
Test creating new RouteTable using minimal set of parameters
172+
#>
173+
function Test-RouteTableCRUDMinimalParameters
174+
{
175+
# Setup
176+
$rgname = Get-ResourceGroupName;
177+
$rglocation = Get-ProviderLocation ResourceManagement;
178+
$rname = Get-ResourceName;
179+
$resourceTypeParent = "Microsoft.Network/RouteTables";
180+
$location = Get-ProviderLocation $resourceTypeParent;
181+
# Dependency parameters
182+
$RouteName = "RouteName";
183+
$RouteAddressPrefix = "10.0.0.0/8";
184+
185+
try
186+
{
187+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation;
188+
189+
# Create required dependencies
190+
$Route = New-AzureRmRouteConfig -Name $RouteName -AddressPrefix $RouteAddressPrefix;
191+
192+
# Create RouteTable
193+
$vRouteTable = New-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname -Location $location -Route $Route;
194+
Assert-NotNull $vRouteTable;
195+
Assert-AreEqual $rname $vRouteTable.Name;
196+
197+
# Get RouteTable
198+
$vRouteTable = Get-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname;
199+
Assert-AreEqual $rname $vRouteTable.Name;
200+
201+
# Remove RouteTable
202+
$removeRouteTable = Remove-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname -PassThru -Force;
203+
Assert-AreEqual $true $removeRouteTable;
204+
}
205+
finally
206+
{
207+
# Cleanup
208+
Clean-ResourceGroup $rgname;
209+
}
210+
}
211+
212+
<#
213+
.SYNOPSIS
214+
Test creating new RouteTable
215+
#>
216+
function Test-RouteTableCRUDAllParameters
217+
{
218+
# Setup
219+
$rgname = Get-ResourceGroupName;
220+
$rglocation = Get-ProviderLocation ResourceManagement;
221+
$rname = Get-ResourceName;
222+
$resourceTypeParent = "Microsoft.Network/RouteTables";
223+
$location = Get-ProviderLocation $resourceTypeParent;
224+
# Resource's parameters
225+
$Tag = @{tag1='test'};
226+
# Resource's parameters for Set test
227+
$TagSet = @{tag2='testSet'};
228+
# Dependency parameters
229+
$RouteName = "RouteName";
230+
$RouteAddressPrefix = "10.0.0.0/8";
231+
232+
try
233+
{
234+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation;
235+
236+
# Create required dependencies
237+
$Route = New-AzureRmRouteConfig -Name $RouteName -AddressPrefix $RouteAddressPrefix;
238+
239+
# Create RouteTable
240+
$vRouteTable = New-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname -Location $location -Route $Route -Tag $Tag;
241+
Assert-NotNull $vRouteTable;
242+
Assert-AreEqual $rname $vRouteTable.Name;
243+
Assert-AreEqualObjectProperties $Tag $vRouteTable.Tag;
244+
245+
# Get RouteTable
246+
$vRouteTable = Get-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname;
247+
Assert-AreEqual $rname $vRouteTable.Name;
248+
Assert-AreEqualObjectProperties $Tag $vRouteTable.Tag;
249+
250+
# Set RouteTable
251+
$vRouteTable.Tag = $TagSet
252+
$vRouteTable = Set-AzureRmRouteTable -RouteTable $vRouteTable;
253+
Assert-NotNull $vRouteTable;
254+
Assert-AreEqual $rname $vRouteTable.Name;
255+
Assert-AreEqualObjectProperties $TagSet $vRouteTable.Tag;
256+
257+
# Get RouteTable
258+
$vRouteTable = Get-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname;
259+
Assert-AreEqual $rname $vRouteTable.Name;
260+
Assert-AreEqualObjectProperties $TagSet $vRouteTable.Tag;
261+
262+
# Remove RouteTable
263+
$removeRouteTable = Remove-AzureRmRouteTable -ResourceGroupName $rgname -Name $rname -PassThru -Force;
264+
Assert-AreEqual $true $removeRouteTable;
265+
}
266+
finally
267+
{
268+
# Cleanup
269+
Clean-ResourceGroup $rgname;
270+
}
271+
}

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTestsGenerated/TestRouteCRUDAllParameters.json

Lines changed: 1787 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTestsGenerated/TestRouteCRUDMinimalParameters.json

Lines changed: 1787 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTestsGenerated/TestRouteTableCRUDAllParameters.json

Lines changed: 1189 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTestsGenerated/TestRouteTableCRUDMinimalParameters.json

Lines changed: 869 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)