Skip to content

Commit 0a64808

Browse files
committed
Finish and run tests
1 parent 7f9c897 commit 0a64808

File tree

5 files changed

+339
-2
lines changed

5 files changed

+339
-2
lines changed

src/ResourceManager/Profile/Commands.Profile.Test/ArgumentCompleterTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,16 @@ public ArgumentCompleterTests(ITestOutputHelper output)
3737

3838
[Fact]
3939
[Trait(Category.AcceptanceType, Category.CheckIn)]
40-
public void DefaultResourceGroup()
40+
public void TestLocationCompleter()
4141
{
4242
ProfileController.NewInstance.RunPsTest(xunitLogger, "72f988bf-86f1-41af-91ab-2d7cd011db47", "Test-LocationCompleter");
4343
}
44+
45+
[Fact]
46+
[Trait(Category.AcceptanceType, Category.CheckIn)]
47+
public void TestResourceGroupCompleter()
48+
{
49+
ProfileController.NewInstance.RunPsTest(xunitLogger, "72f988bf-86f1-41af-91ab-2d7cd011db47", "Test-ResourceGroupCompleter");
50+
}
4451
}
4552
}

src/ResourceManager/Profile/Commands.Profile.Test/ArgumentCompleterTests.ps1

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ Tests location completer
1818
#>
1919
function Test-LocationCompleter
2020
{
21-
$filePath = Join-Path -Path $PSScriptRoot -ChildPath "\bin\Debug\Microsoft.Azure.Commands.ResourceManager.Common.dll"
21+
$filePath = Join-Path -Path $PSScriptRoot -ChildPath "\Microsoft.Azure.Commands.ResourceManager.Common.dll"
2222
$assembly = [System.Reflection.Assembly]::LoadFrom($filePath)
23+
$resourceTypes = @("Microsoft.Batch/operations")
24+
$locations = [Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.LocationCompleterAttribute]::FindLocations($resourceTypes)
25+
$expectedResourceType = Get-AzureRmResourceProvider -ProviderNamespace "Microsoft.Batch" | Where-Object {$_.ResourceTypes.ResourceTypeName -eq "operations"}
26+
$expectedLocations = $expectedResourceType.Locations | ForEach-Object {"`"" + $_ + "`""}
27+
Assert-AreEqualArray $locations $expectedLocations
28+
}
29+
30+
31+
<#
32+
.SYNOPSIS
33+
Tests resource group completer
34+
#>
35+
function Test-ResourceGroupCompleter
36+
{
37+
$filePath = Join-Path -Path $PSScriptRoot -ChildPath "\Microsoft.Azure.Commands.ResourceManager.Common.dll"
38+
$assembly = [System.Reflection.Assembly]::LoadFrom($filePath)
39+
$resourceGroups = [Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute]::GetResourceGroups()
40+
$expectResourceGroups = Get-AzureRmResourceGroup | ForEach-Object {$_.ResourceGroupName}
41+
Assert-AreEqualArray $resourceGroups $expectResourceGroups
2342
}

src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
</Reference>
188188
</ItemGroup>
189189
<ItemGroup>
190+
<Compile Include="ArgumentCompleterTests.cs" />
190191
<Compile Include="AutosaveTests.cs" />
191192
<Compile Include="AzureRmProfileTests.cs" />
192193
<Compile Include="ClientFactoryTests.cs" />
@@ -227,10 +228,19 @@
227228
<SubType>Designer</SubType>
228229
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
229230
</None>
231+
<None Include="ArgumentCompleterTests.ps1">
232+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
233+
</None>
230234
<None Include="MSSharedLibKey.snk" />
231235
<None Include="packages.config">
232236
<SubType>Designer</SubType>
233237
</None>
238+
<None Include="SessionRecords\Microsoft.Azure.Commands.Profile.Test.ArgumentCompleterTests\TestLocationCompleter.json">
239+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
240+
</None>
241+
<None Include="SessionRecords\Microsoft.Azure.Commands.Profile.Test.ArgumentCompleterTests\TestResourceGroupCompleter.json">
242+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
243+
</None>
234244
<None Include="SessionRecords\Microsoft.Azure.Commands.Profile.Test.DefaultCmdletTests\DefaultResourceGroup.json">
235245
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
236246
</None>

src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.ArgumentCompleterTests/TestLocationCompleter.json

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

0 commit comments

Comments
 (0)