Skip to content

Commit 98ad127

Browse files
author
maddieclayton
authored
Merge pull request Azure#4951 from maddieclayton/ACtests
Add scenario tests for completers
2 parents 4d5f223 + 191ed51 commit 98ad127

File tree

5 files changed

+405
-0
lines changed

5 files changed

+405
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.ResourceManager.Common;
16+
using Microsoft.Azure.Commands.Resources.Test.ScenarioTests;
17+
using Microsoft.Azure.Commands.ScenarioTest;
18+
using Microsoft.Azure.ServiceManagemenet.Common.Models;
19+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
20+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
21+
using Xunit;
22+
using Xunit.Abstractions;
23+
24+
namespace Microsoft.Azure.Commands.Profile.Test
25+
{
26+
public class ArgumentCompleterTests : RMTestBase
27+
{
28+
private XunitTracingInterceptor xunitLogger;
29+
30+
public ArgumentCompleterTests(ITestOutputHelper output)
31+
{
32+
TestExecutionHelpers.SetUpSessionAndProfile();
33+
ResourceManagerProfileProvider.InitializeResourceManagerProfile(true);
34+
35+
xunitLogger = new XunitTracingInterceptor(output);
36+
}
37+
38+
[Fact]
39+
[Trait(Category.AcceptanceType, Category.CheckIn)]
40+
public void TestLocationCompleter()
41+
{
42+
ProfileController.NewInstance.RunPsTest(xunitLogger, "72f988bf-86f1-41af-91ab-2d7cd011db47", "Test-LocationCompleter");
43+
}
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+
}
51+
}
52+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
<#
16+
.SYNOPSIS
17+
Tests location completer
18+
#>
19+
function Test-LocationCompleter
20+
{
21+
$filePath = Join-Path -Path $PSScriptRoot -ChildPath "\Microsoft.Azure.Commands.ResourceManager.Common.dll"
22+
$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
42+
}

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)