Skip to content

Commit bcfbd2d

Browse files
committed
Modernize and standardize tests
Primary change is to how we use location, it is no longer hard coded. Some minor changes to naming
1 parent 999423f commit bcfbd2d

25 files changed

+318
-420
lines changed

src/LogicApp/LogicApp.Test/ScenarioTests/Common.ps1

Lines changed: 11 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -13,58 +13,16 @@
1313

1414
<#
1515
.SYNOPSIS
16-
Gets valid resource group name
17-
#>
18-
function Get-ResourceGroupName
19-
{
20-
return getAssetName
21-
}
22-
23-
<#
24-
.SYNOPSIS
25-
Gets valid resource name
16+
Creates a resource group to use in tests
2617
#>
27-
function Get-ResourceName
18+
function CurrentApiVersion
2819
{
29-
return getAssetName
20+
return "2018-07-01-preview"
3021
}
3122

32-
<#
33-
.SYNOPSIS
34-
Gets the default location for a provider
35-
#>
36-
function Get-ProviderLocation($provider)
23+
function SampleMetadata
3724
{
38-
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
39-
{
40-
$namespace = $provider.Split("/")[0]
41-
if($provider.Contains("/"))
42-
{
43-
$type = $provider.Substring($namespace.Length + 1)
44-
$location = Get-AzResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
45-
46-
if ($location -eq $null)
47-
{
48-
return "West US"
49-
} else
50-
{
51-
return $location.Locations[0]
52-
}
53-
}
54-
55-
return "West US"
56-
}
57-
58-
return "WestUS"
59-
}
60-
61-
<#
62-
.SYNOPSIS
63-
Gets the default test location name.
64-
#>
65-
function Get-LocationName()
66-
{
67-
return 'brazilsouth'
25+
return @{ "key1" = "value1"; "key2" = "value2"; "key3" = "value3"; }
6826
}
6927

7028
<#
@@ -73,22 +31,10 @@ Creates a resource group to use in tests
7331
#>
7432
function TestSetup-CreateResourceGroup
7533
{
76-
$resourceGroupName = getAssetName
77-
$rglocation = Get-ProviderLocation "North Europe"
78-
$resourceGroup = New-AzResourceGroup -Name $resourceGroupName -location $rglocation -Force
79-
80-
return $resourceGroup
81-
}
34+
$resourceGroupName = "RG-" + (getAssetname)
35+
$location = Get-Location "Microsoft.Resources" "resourceGroups" "West US"
36+
$resourceGroup = New-AzResourceGroup -Name $resourceGroupName -location $location
8237

83-
<#
84-
.SYNOPSIS
85-
Creates named resource group to use in tests
86-
#>
87-
function TestSetup-CreateNamedResourceGroup([string]$resourceGroupName)
88-
{
89-
$location = Get-LocationName
90-
$resourceGroup = New-AzResourceGroup -Name $resourceGroupName -location $location -Force
91-
9238
return $resourceGroup
9339
}
9440

@@ -98,7 +44,7 @@ Creates a new Integration account
9844
#>
9945
function TestSetup-CreateIntegrationAccount ([string]$resourceGroupName, [string]$integrationAccountName)
10046
{
101-
$location = Get-LocationName
47+
$location = Get-Location "Microsoft.Logic" "integrationAccounts" "West US"
10248
$integrationAccount = New-AzIntegrationAccount -ResourceGroupName $resourceGroupName -IntegrationAccountName $integrationAccountName -Location $location -Sku "Standard"
10349
return $integrationAccount
10450
}
@@ -109,14 +55,12 @@ Creates a new workflow
10955
#>
11056
function TestSetup-CreateWorkflow ([string]$resourceGroupName, [string]$workflowName, [string]$AppServicePlan)
11157
{
112-
$rglocation = Get-ProviderLocation "North Europe"
58+
$location = Get-Location "Microsoft.Logic" "workflows" "West US"
11359
$resourceGroup = New-AzResourceGroup -Name $resourceGroupName -location $rglocation -Force
11460

115-
TestSetup-CreateAppServicePlan $resourceGroupName $AppServicePlan
116-
11761
$definitionFilePath = Join-Path "Resources" "TestSimpleWorkflowDefinition.json"
11862
$parameterFilePath = Join-Path "Resources" "TestSimpleWorkflowParameter.json"
119-
$workflow = $resourceGroup | New-AzLogicApp -Name $workflowName -Location $WORKFLOW_LOCATION -DefinitionFilePath $definitionFilePath -ParameterFilePath $parameterFilePath
63+
$workflow = $resourceGroup | New-AzLogicApp -Name $workflowName -Location $location -DefinitionFilePath $definitionFilePath -ParameterFilePath $parameterFilePath
12064
return $workflow
12165
}
12266

src/LogicApp/LogicApp.Test/ScenarioTests/IntegrationAccountAgreementTests.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public IntegrationAccountAgreementTests(Xunit.Abstractions.ITestOutputHelper out
3737
/// </summary>
3838
[Fact]
3939
[Trait(Category.AcceptanceType, Category.CheckIn)]
40-
public void TestCreateIntegrationAccountAgreementX12()
40+
public void TestCreateAgreementX12()
4141
{
4242
WorkflowController.NewInstance.RunPowerShellTest(_logger, "Test-CreateIntegrationAccountAgreementX12");
4343
}
@@ -47,18 +47,17 @@ public void TestCreateIntegrationAccountAgreementX12()
4747
/// </summary>
4848
[Fact]
4949
[Trait(Category.AcceptanceType, Category.CheckIn)]
50-
public void TestCreateIntegrationAccountAgreementWithFailure()
50+
public void TestCreateAgreementWithFailure()
5151
{
52-
WorkflowController.NewInstance.RunPowerShellTest(
53-
_logger, "Test-CreateIntegrationAccountAgreementWithFailure");
52+
WorkflowController.NewInstance.RunPowerShellTest(_logger, "Test-CreateIntegrationAccountAgreementWithFailure");
5453
}
5554

5655
/// <summary>
5756
/// Test New-AzIntegrationAccountAgreement command to create a new AS2 integration account agreement.
5857
/// </summary>
5958
[Fact]
6059
[Trait(Category.AcceptanceType, Category.CheckIn)]
61-
public void TestCreateIntegrationAccountAgreementAs2()
60+
public void TestCreateAgreementAs2()
6261
{
6362
WorkflowController.NewInstance.RunPowerShellTest(_logger, "Test-CreateIntegrationAccountAgreementAS2");
6463
}
@@ -68,7 +67,7 @@ public void TestCreateIntegrationAccountAgreementAs2()
6867
/// </summary>
6968
[Fact]
7069
[Trait(Category.AcceptanceType, Category.CheckIn)]
71-
public void TestCreateIntegrationAccountAgreementEdifact()
70+
public void TestCreateAgreementEdifact()
7271
{
7372
WorkflowController.NewInstance.RunPowerShellTest(_logger, "Test-CreateIntegrationAccountAgreementEdifact");
7473
}
@@ -78,7 +77,7 @@ public void TestCreateIntegrationAccountAgreementEdifact()
7877
/// </summary>
7978
[Fact]
8079
[Trait(Category.AcceptanceType, Category.CheckIn)]
81-
public void TestGetIntegrationAccountAgreement()
80+
public void TestGetAgreement()
8281
{
8382
WorkflowController.NewInstance.RunPowerShellTest(_logger, "Test-GetIntegrationAccountAgreement");
8483
}
@@ -88,17 +87,17 @@ public void TestGetIntegrationAccountAgreement()
8887
/// </summary>
8988
[Fact]
9089
[Trait(Category.AcceptanceType, Category.CheckIn)]
91-
public void TestRemoveIntegrationAccountAgreement()
90+
public void TestRemoveAgreement()
9291
{
9392
WorkflowController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveIntegrationAccountAgreement");
94-
}
93+
}
9594

9695
/// <summary>
9796
/// Test Set-AzIntegrationAccountAgreement command to update the integration account agreement.
9897
/// </summary>
9998
[Fact]
10099
[Trait(Category.AcceptanceType, Category.CheckIn)]
101-
public void TestUpdateIntegrationAccountAgreement()
100+
public void TestUpdateAgreement()
102101
{
103102
WorkflowController.NewInstance.RunPowerShellTest(_logger, "Test-UpdateIntegrationAccountAgreement");
104103
}
@@ -108,10 +107,9 @@ public void TestUpdateIntegrationAccountAgreement()
108107
/// </summary>
109108
[Fact]
110109
[Trait(Category.AcceptanceType, Category.CheckIn)]
111-
public void TestListIntegrationAccountAgreement()
110+
public void TestListAgreement()
112111
{
113112
WorkflowController.NewInstance.RunPowerShellTest(_logger, "Test-ListIntegrationAccountAgreement");
114113
}
115114
}
116-
}
117-
115+
}

src/LogicApp/LogicApp.Test/ScenarioTests/IntegrationAccountAgreementTests.ps1

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ Test New-AzIntegrationAccountAgreement command
1818
#>
1919
function Test-CreateIntegrationAccountAgreementX12
2020
{
21-
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountX12AgreementContent.json"
21+
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "X12AgreementContent.json"
2222
$agreementX12Content = [IO.File]::ReadAllText($agreementX12FilePath)
2323

24-
$resourceGroupName = getAssetname
25-
$resourceGroup = TestSetup-CreateNamedResourceGroup $resourceGroupName
26-
$integrationAccountName = getAssetname
24+
$resourceGroup = TestSetup-CreateResourceGroup
25+
$integrationAccountName = "IA-" + (getAssetname)
2726

2827
$integrationAccountX12AgreementName = getAssetname
2928
$integrationAccountX12AgreementName1 = getAssetname
@@ -66,12 +65,11 @@ Test New-AzIntegrationAccountAgreement command
6665
#>
6766
function Test-CreateIntegrationAccountAgreementAS2
6867
{
69-
$agreementAS2FilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountAS2AgreementContent.json"
68+
$agreementAS2FilePath = Join-Path $TestOutputRoot "Resources" "AS2AgreementContent.json"
7069
$agreementAS2Content = [IO.File]::ReadAllText($agreementAS2FilePath)
7170

72-
$resourceGroupName = getAssetname
73-
$resourceGroup = TestSetup-CreateNamedResourceGroup $resourceGroupName
74-
$integrationAccountName = getAssetname
71+
$resourceGroup = TestSetup-CreateResourceGroup
72+
$integrationAccountName = "IA-" + (getAssetname)
7573

7674
$integrationAccountAS2AgreementName = getAssetname
7775
$integrationAccountAS2AgreementName1 = getAssetname
@@ -100,12 +98,11 @@ Test New-AzIntegrationAccountAgreement command
10098
#>
10199
function Test-CreateIntegrationAccountAgreementEdifact
102100
{
103-
$agreementEdifactFilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountEdifactAgreementContent.json"
101+
$agreementEdifactFilePath = Join-Path $TestOutputRoot "Resources" "EdifactAgreementContent.json"
104102
$agreementEdifactContent = [IO.File]::ReadAllText($agreementEdifactFilePath)
105103

106-
$resourceGroupName = getAssetname
107-
$resourceGroup = TestSetup-CreateNamedResourceGroup $resourceGroupName
108-
$integrationAccountName = getAssetname
104+
$resourceGroup = TestSetup-CreateResourceGroup
105+
$integrationAccountName = "IA-" + (getAssetname)
109106

110107
$integrationAccountEdifactAgreementName = getAssetname
111108
$integrationAccountEdifactAgreementName1 = getAssetname
@@ -135,12 +132,11 @@ Test New-AzIntegrationAccountAgreement command with negative scenario.
135132
#>
136133
function Test-CreateIntegrationAccountAgreementWithFailure
137134
{
138-
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountX12AgreementContent.json"
135+
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "X12AgreementContent.json"
139136
$agreementX12Content = [IO.File]::ReadAllText($agreementX12FilePath)
140137

141-
$resourceGroupName = getAssetname
142-
$resourceGroup = TestSetup-CreateNamedResourceGroup $resourceGroupName
143-
$integrationAccountName = getAssetname
138+
$resourceGroup = TestSetup-CreateResourceGroup
139+
$integrationAccountName = "IA-" + (getAssetname)
144140

145141
$integrationAccountX12AgreementName = getAssetname
146142

@@ -170,14 +166,13 @@ Test Get-AzIntegrationAccountAgreement command
170166
#>
171167
function Test-GetIntegrationAccountAgreement
172168
{
173-
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountX12AgreementContent.json"
169+
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "X12AgreementContent.json"
174170
$agreementX12Content = [IO.File]::ReadAllText($agreementX12FilePath)
175171

176172
Assert-ThrowsContains { Get-AzIntegrationAccountAgreement -ResourceGroupName "Random83da135" -IntegrationAccountName "DoesNotMatter" -AgreementName "DoesNotMatter" } "Resource group 'Random83da135' could not be found."
177173

178-
$resourceGroupName = getAssetname
179-
$resourceGroup = TestSetup-CreateNamedResourceGroup $resourceGroupName
180-
$integrationAccountName = getAssetname
174+
$resourceGroup = TestSetup-CreateResourceGroup
175+
$integrationAccountName = "IA-" + (getAssetname)
181176

182177
$integrationAccountX12AgreementName = getAssetname
183178

@@ -207,14 +202,13 @@ Test Remove-AzIntegrationAccountAgreement command
207202
#>
208203
function Test-RemoveIntegrationAccountAgreement
209204
{
210-
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountX12AgreementContent.json"
205+
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "X12AgreementContent.json"
211206
$agreementX12Content = [IO.File]::ReadAllText($agreementX12FilePath)
212207

213-
$resourceGroupName = getAssetname
214-
$resourceGroup = TestSetup-CreateNamedResourceGroup $resourceGroupName
215-
$integrationAccountName = getAssetname
208+
$resourceGroup = TestSetup-CreateResourceGroup
209+
$integrationAccountName = "IA-" + (getAssetname)
216210

217-
$integrationAccountX12AgreementName = getAssetname
211+
$integrationAccountX12AgreementName = getAssetname
218212

219213
$integrationAccount = TestSetup-CreateIntegrationAccount $resourceGroup.ResourceGroupName $integrationAccountName
220214

@@ -238,15 +232,14 @@ Test Set-AzIntegrationAccountAgreement command
238232
#>
239233
function Test-UpdateIntegrationAccountAgreement
240234
{
241-
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountX12AgreementContent.json"
235+
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "X12AgreementContent.json"
242236
$agreementX12Content = [IO.File]::ReadAllText($agreementX12FilePath)
243237

244-
$agreementAS2FilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountAS2AgreementContent.json"
238+
$agreementAS2FilePath = Join-Path $TestOutputRoot "Resources" "AS2AgreementContent.json"
245239
$agreementAS2Content = [IO.File]::ReadAllText($agreementAS2FilePath)
246240

247-
$resourceGroupName = getAssetname
248-
$resourceGroup = TestSetup-CreateNamedResourceGroup $resourceGroupName
249-
$integrationAccountName = getAssetname
241+
$resourceGroup = TestSetup-CreateResourceGroup
242+
$integrationAccountName = "IA-" + (getAssetname)
250243

251244
$integrationAccountAgreementName = getAssetname
252245

@@ -324,12 +317,11 @@ Test Get-AzIntegrationAccountAgreement command : paging test
324317
#>
325318
function Test-ListIntegrationAccountAgreement
326319
{
327-
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "IntegrationAccountX12AgreementContent.json"
320+
$agreementX12FilePath = Join-Path $TestOutputRoot "Resources" "X12AgreementContent.json"
328321
$agreementX12Content = [IO.File]::ReadAllText($agreementX12FilePath)
329322

330-
$resourceGroupName = getAssetname
331-
$resourceGroup = TestSetup-CreateNamedResourceGroup $resourceGroupName
332-
$integrationAccountName = getAssetname
323+
$resourceGroup = TestSetup-CreateResourceGroup
324+
$integrationAccountName = "IA-" + (getAssetname)
333325

334326
$integrationAccount = TestSetup-CreateIntegrationAccount $resourceGroup.ResourceGroupName $integrationAccountName
335327

0 commit comments

Comments
 (0)