Skip to content

Commit 8e191cc

Browse files
committed
Addressing pull request comments
1 parent bd5c67f commit 8e191cc

File tree

12 files changed

+321
-700
lines changed

12 files changed

+321
-700
lines changed

src/ResourceManager/Dns/Commands.Dns.Test/Commands.Dns.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
<Compile Include="ScenarioTests\ZoneTests.cs" />
138138
<Compile Include="ScenarioTests\RecordsTests.cs" />
139139
<Compile Include="ScenarioTests\DnsTestsBase.cs" />
140+
<Compile Include="UnitTests\GetAzureDnsRecordSetTests.cs" />
141+
<Compile Include="UnitTests\GetAzureDnsZoneTests.cs" />
140142
</ItemGroup>
141143
<ItemGroup>
142144
<ProjectReference Include="..\..\..\Common\Commands.ScenarioTests.Common\Commands.ScenarioTests.Common.csproj">
@@ -195,7 +197,6 @@
195197
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetEtagMismatch.json" />
196198
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetGet.json" />
197199
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetGetWithEndsWith.json" />
198-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetGetWithEndsWithAndName.json" />
199200
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetMX.json" />
200201
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetNS.json" />
201202
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetRemoveRecordTypeMismatch.json" />
@@ -205,7 +206,6 @@
205206
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudWithPiping.json" />
206207
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneList.json" />
207208
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneListWithEndsWith.json" />
208-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneListWithEndsWithAndName.json" />
209209
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneRemoveEtagMismatch.json" />
210210
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneRemoveNotFound.json" />
211211
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneSetEtagMismatch.json" />

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/RecordsTests.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,5 @@ public void TestRecordSetGetWithEndsWith()
145145
{
146146
RunPowerShellTest("Test-RecordSetGetWithEndsWith");
147147
}
148-
149-
[Fact]
150-
[Trait(Category.AcceptanceType, Category.CheckIn)]
151-
public void TestRecordSetGetWithEndsWithAndName()
152-
{
153-
RunPowerShellTest("Test-RecordSetGetWithEndsWithAndName");
154-
}
155148
}
156149
}

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/RecordsTests.ps1

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -628,35 +628,5 @@ function Test-RecordSetGetWithEndsWith
628628
$zone | Remove-AzureDnsRecordSet -Name $recordName2 -RecordType AAAA -Force
629629
$zone | Remove-AzureDnsRecordSet -Name $recordName3 -RecordType MX -Force
630630

631-
$zone | Remove-AzureDnsZone -Force -IgnoreEtag
632-
}
633-
634-
<#
635-
.SYNOPSIS
636-
Record Set Get using EndsWith parameter and Name parameter. Should throw exception.
637-
#>
638-
function Test-RecordSetGetWithEndsWithAndName
639-
{
640-
$rootRecordName = "@"
641-
$recordSuffix = ".com"
642-
$zoneName = getAssetname
643-
$recordName1 = getAssetname + $recordSuffix
644-
$recordName2 = getAssetname
645-
$recordName3 = getAssetname + $recordSuffix
646-
647-
$zone = TestSetup-CreateResourceGroup | New-AzureDnsZone -Name $zoneName
648-
649-
New-AzureDnsRecordSet -Zone $zone -Name $recordName1 -Ttl 100 -RecordType AAAA
650-
New-AzureDnsRecordSet -Zone $zone -Name $recordName2 -Ttl 1200 -RecordType AAAA
651-
New-AzureDnsRecordSet -Zone $zone -Name $recordName3 -Ttl 1500 -RecordType MX
652-
653-
Assert-Throws { $zone | Get-AzureDnsRecordSet -Name $recordName1 -RecordType AAAA -EndsWith $recordSuffix } "Name parameter cannot be used with EndsWith."
654-
655-
Assert-Throws { $zone | Get-AzureDnsRecordSet -Name $recordName1 -EndsWith $recordSuffix } "Name parameter cannot be used with EndsWith."
656-
657-
$zone | Remove-AzureDnsRecordSet -Name $recordName1 -RecordType AAAA -Force
658-
$zone | Remove-AzureDnsRecordSet -Name $recordName2 -RecordType AAAA -Force
659-
$zone | Remove-AzureDnsRecordSet -Name $recordName3 -RecordType MX -Force
660-
661631
$zone | Remove-AzureDnsZone -Force -IgnoreEtag
662632
}

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/ZoneTests.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ public void TestZoneListWithEndsWith()
4747
{
4848
RunPowerShellTest("Test-ZoneListWithEndsWith");
4949
}
50-
51-
[Fact]
52-
[Trait(Category.AcceptanceType, Category.CheckIn)]
53-
public void TestZoneListWithEndsWithAndName()
54-
{
55-
RunPowerShellTest("Test-ZoneListWithEndsWithAndName");
56-
}
5750

5851
[Fact(Skip = "Service does not yet support this")]
5952
[Trait(Category.AcceptanceType, Category.CheckIn)]

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/ZoneTests.ps1

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,4 @@ function Test-ZoneListWithEndsWith
227227
Assert-NotNull $resourceGroup.ResourceGroupName $result[0].ResourceGroupName
228228

229229
$result | Remove-AzureDnsZone -PassThru -Force
230-
}
231-
232-
<#
233-
.SYNOPSIS
234-
Zone List With EndsWith
235-
#>
236-
function Test-ZoneListWithEndsWithAndName
237-
{
238-
$suffix = ".com"
239-
$suffixWithDot = ".com."
240-
$zoneName1 = getAssetname
241-
$zoneName2 = $zoneName1 + $suffix
242-
$resourceGroup = TestSetup-CreateResourceGroup
243-
$createdZone1 = $resourceGroup | New-AzureDnsZone -Name $zoneName1
244-
$createdZone2 = $resourceGroup | New-AzureDnsZone -Name $zoneName2
245-
246-
Assert-Throws { Get-AzureDnsZone -ResourceGroupName $resourceGroup.ResourceGroupName -Name $zoneName2 -EndsWith $suffixWithDot } "Name parameter cannot be used with EndsWith."
247230
}

src/ResourceManager/Dns/Commands.Dns.Test/SessionRecords/Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests/TestRecordSetGetWithEndsWith.json

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

src/ResourceManager/Dns/Commands.Dns.Test/SessionRecords/Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests/TestZoneListWithEndsWith.json

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

src/ResourceManager/Dns/Commands.Dns.Test/SessionRecords/Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests/TestZoneListWithEndsWithAndName.json

Lines changed: 0 additions & 397 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
namespace Microsoft.Azure.Commands.Dns.Test.UnitTests
16+
{
17+
using System.Management.Automation;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Xunit;
20+
21+
public class GetAzureDnsRecordSetTests
22+
{
23+
[Fact]
24+
[Trait(Category.AcceptanceType, Category.CheckIn)]
25+
public void GetAzureDnsRecordSetThrowsExceptionWhenUsingNameAndEndsWith()
26+
{
27+
var cmdlet = new GetAzureDnsRecordSet
28+
{
29+
Name = "record",
30+
ZoneName = "zone.com",
31+
ResourceGroupName = "resourceGroup",
32+
Zone = new DnsZone
33+
{
34+
Name = "zone.com",
35+
ResourceGroupName = "resourceGroup"
36+
},
37+
RecordType = "A",
38+
EndsWith = ".com."
39+
};
40+
41+
Assert.Throws<PSArgumentException>(() => cmdlet.ExecuteCmdlet());
42+
}
43+
}
44+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
namespace Microsoft.Azure.Commands.Dns.Test.UnitTests
16+
{
17+
using System.Management.Automation;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Xunit;
20+
21+
public class GetAzureDnsZoneTests
22+
{
23+
[Fact]
24+
[Trait(Category.AcceptanceType, Category.CheckIn)]
25+
public void GetAzureDnsZoneThrowsExceptionWhenUsingNameAndEndsWith()
26+
{
27+
var cmdlet = new GetAzureDnsZone
28+
{
29+
Name = "record",
30+
ResourceGroupName = "resourceGroup",
31+
EndsWith = ".com."
32+
};
33+
34+
Assert.Throws<PSArgumentException>(() => cmdlet.ExecuteCmdlet());
35+
}
36+
}
37+
}

src/ResourceManager/Dns/Commands.Dns/Records/GetAzureDnsRescordSet.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class GetAzureDnsRecordSet : DnsBaseCmdlet
5050
[ValidateNotNullOrEmpty]
5151
public string RecordType { get; set; }
5252

53-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The relative name suffix to search.")]
53+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The single or multiple label suffix to search in the relative name.")]
5454
[ValidateNotNullOrEmpty]
5555
public string EndsWith { get; set; }
5656

@@ -80,8 +80,7 @@ public override void ExecuteCmdlet()
8080
{
8181
throw new PSArgumentException(ProjectResources.Error_NameAndEndsWith);
8282
}
83-
84-
if (this.Name != null)
83+
else if (this.Name != null)
8584
{
8685
if (this.RecordType == null)
8786
{

src/ResourceManager/Dns/Commands.Dns/Zones/GetAzureDnsZone.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class GetAzureDnsZone : DnsBaseCmdlet
3434
[ValidateNotNullOrEmpty]
3535
public string ResourceGroupName { get; set; }
3636

37-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The relative name suffix to search.")]
37+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The single or multiple label suffix to search in the zone name.")]
3838
[ValidateNotNullOrEmpty]
3939
public string EndsWith { get; set; }
4040

@@ -44,8 +44,7 @@ public override void ExecuteCmdlet()
4444
{
4545
throw new PSArgumentException(ProjectResources.Error_NameAndEndsWith);
4646
}
47-
48-
if (this.Name != null)
47+
else if (this.Name != null)
4948
{
5049
WriteObject(this.DnsClient.GetDnsZone(this.Name, this.ResourceGroupName));
5150
}

0 commit comments

Comments
 (0)