Skip to content

Commit 8fa470a

Browse files
committed
Added Resource Id-s to sub resources, and soem test changes.
1 parent d9c448b commit 8fa470a

17 files changed

+243
-274
lines changed

src/ResourceManager/DataFactories/Commands.DataFactoryV2.Test/Commands.DataFactoryV2.Test.csproj

Lines changed: 3 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -145,124 +145,13 @@
145145
<None Include="packages.config">
146146
<SubType>Designer</SubType>
147147
</None>
148-
<None Include="Resources\dataset-ds1_0.json">
148+
<None Include="Resources\*.json">
149149
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
150150
</None>
151-
<None Include="Resources\dataset-ds0_0.json">
151+
<None Include="ScenarioTests\*.ps1">
152152
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
153153
</None>
154-
<None Include="Resources\dataset-dsIn.json">
155-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
156-
</None>
157-
<None Include="Resources\scheduleTriggerWithPipeline.json">
158-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
159-
</None>
160-
<None Include="Resources\scheduletrigger.json">
161-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
162-
</None>
163-
<None Include="Resources\linkedService.json">
164-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
165-
</None>
166-
<None Include="Resources\dataset.json">
167-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
168-
</None>
169-
<None Include="Resources\pipeline.json">
170-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
171-
</None>
172-
<None Include="Resources\queryRuns.json">
173-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
174-
</None>
175-
<None Include="ScenarioTests\Common.ps1">
176-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
177-
</None>
178-
<None Include="ScenarioTests\IntegrationRuntimeTests.ps1">
179-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
180-
</None>
181-
<None Include="ScenarioTests\TriggerTests.ps1">
182-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
183-
</None>
184-
<None Include="ScenarioTests\PipelineTests.ps1">
185-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
186-
</None>
187-
<None Include="ScenarioTests\RunTests.ps1">
188-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
189-
</None>
190-
<None Include="ScenarioTests\DatasetTests.ps1">
191-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
192-
</None>
193-
<None Include="ScenarioTests\LinkedServiceTests.ps1">
194-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
195-
</None>
196-
<None Include="ScenarioTests\DataFactoryTests.ps1">
197-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
198-
</None>
199-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DataFactoryTests\TestCreateDataFactoryV2.json">
200-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
201-
</None>
202-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DataFactoryTests\TestDataFactoryPipingV2.json">
203-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
204-
</None>
205-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DataFactoryTests\TestDeleteDataFactoryWithDataFactoryParameterV2.json">
206-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
207-
</None>
208-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DataFactoryTests\TestGetDataFactoriesInSubscriptionV2.json">
209-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
210-
</None>
211-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DataFactoryTests\TestGetNonExistingDataFactoryV2.json">
212-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
213-
</None>
214-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DatasetTests\TestDatasetWithResourceIdV2.json">
215-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
216-
</None>
217-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.LinkedServiceTests\TestLinkedServiceV2.json">
218-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
219-
</None>
220-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.LinkedServiceTests\TestLinkedServicePipingV2.json">
221-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
222-
</None>
223-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.LinkedServiceTests\TestLinkedServiceWithDataFactoryParameterV2.json">
224-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
225-
</None>
226-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.LinkedServiceTests\TestLinkedServiceWithResourceIdV2.json">
227-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
228-
</None>
229-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.PipelineTests\TestPipelineV2.json">
230-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
231-
</None>
232-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DatasetTests\TestDatasetV2.json">
233-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
234-
</None>
235-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DatasetTests\TestDatasetPipingV2.json">
236-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
237-
</None>
238-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.DatasetTests\TestDatasetWithDataFactoryParameterV2.json">
239-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
240-
</None>
241-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.PipelineTests\TestPipelineWithResourceIdV2.json">
242-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
243-
</None>
244-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.RunTests\TestRunV2.json">
245-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
246-
</None>
247-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.IntegrationRuntimeTests\TestSelfHosedIntegrationRuntime.json">
248-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
249-
</None>
250-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.IntegrationRuntimeTests\TestManagedElasticIntegrationRuntime.json">
251-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
252-
</None>
253-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.IntegrationRuntimeTests\TestIntegrationRuntimePiping.json">
254-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
255-
</None>
256-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.TriggerTests\TestTrigger.json">
257-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
258-
</None>
259-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.TriggerTests\TestTriggerRun.json">
260-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
261-
</None>
262-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.TriggerTests\TestTriggerStartStop.json">
263-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
264-
</None>
265-
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactoryV2.Test.TriggerTests\TestTriggerWithResourceId.json">
154+
<None Include="SessionRecords\**\*.json">
266155
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
267156
</None>
268157
</ItemGroup>

src/ResourceManager/DataFactories/Commands.DataFactoryV2.Test/ScenarioTests/Common.ps1

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ function Get-ProviderLocation($provider)
4242

4343
<#
4444
.SYNOPSIS
45-
Cleans the created data factory
45+
Cleans the created resources
4646
#>
47-
function Clean-DataFactory($rgname, $dfname)
47+
function CleanUp($rgname, $dfname)
4848
{
4949
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback) {
5050
Remove-AzureRmDataFactoryV2 -ResourceGroupName $rgname -Name $dfname -Force
@@ -54,9 +54,23 @@ function Clean-DataFactory($rgname, $dfname)
5454

5555
<#
5656
.SYNOPSIS
57-
Cleans the created tags
57+
Verifies the properties of two AdfSubResource PS objects
5858
#>
59-
function Clean-Tags
59+
function Verify-AdfSubResource ($expected, $actual, $rgname, $dfname, $name)
6060
{
61-
Get-AzureRmTag | Remove-AzureRmTag -Force
61+
Assert-NotNull $actual.Id
62+
Assert-NotNull $actual.ETag
63+
Assert-NotNull $actual.Name
64+
Assert-NotNull $actual.ResourceGroupName
65+
Assert-NotNull $actual.DataFactoryName
66+
67+
Assert-AreEqual $rgname $actual.ResourceGroupName
68+
Assert-AreEqual $dfname $actual.DataFactoryName
69+
Assert-AreEqual $name $actual.Name
70+
71+
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
72+
Assert-AreEqual $expected.DataFactoryName $actual.DataFactoryName
73+
Assert-AreEqual $expected.Id $actual.Id
74+
Assert-AreEqual $expected.ETag $actual.ETag
75+
Assert-AreEqual $expected.Name $actual.Name
6276
}

src/ResourceManager/DataFactories/Commands.DataFactoryV2.Test/ScenarioTests/DataFactoryTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,12 @@ public void TestDataFactoryPipingV2()
5858
{
5959
RunPowerShellTest("Test-DataFactoryPiping");
6060
}
61+
62+
[Fact]
63+
[Trait(Category.AcceptanceType, Category.CheckIn)]
64+
public void TestGetFactoryByNameParameterSetV2()
65+
{
66+
RunPowerShellTest("Test-GetFactoryByNameParameterSet");
67+
}
6168
}
6269
}

src/ResourceManager/DataFactories/Commands.DataFactoryV2.Test/ScenarioTests/DataFactoryTests.ps1

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<#
1616
.SYNOPSIS
17-
Nagative test. Get resources from an non-existing empty group.
17+
Gets all factories in subscription across multiple resource groups.
1818
#>
1919
function Test-GetDataFactoriesInSubscription
2020
{
@@ -32,26 +32,25 @@ function Test-GetDataFactoriesInSubscription
3232
{
3333
Set-AzureRmDataFactoryV2 -ResourceGroupName $rgname1 -Name $dfname1 -Location $dflocation -Force
3434
Set-AzureRmDataFactoryV2 -ResourceGroupName $rgname2 -Name $dfname2 -Location $dflocation -Force
35-
$expected = Get-AzureRmDataFactoryV2
35+
$fetcheFactories = Get-AzureRmDataFactoryV2
3636

37-
Assert-NotNull $expected
37+
Assert-NotNull $fetcheFactories
3838
$foundDf1 = $false
3939
$foundDf2 = $false
40-
$expected|ForEach-Object {If ($_.DataFactoryName -eq $dfname1) {$foundDf1 = $true}}
41-
$expected|ForEach-Object {If ($_.DataFactoryName -eq $dfname2) {$foundDf2 = $true}}
42-
Assert-True { $foundDf1 }
40+
$fetcheFactories|ForEach-Object {If ($_.DataFactoryName -eq $dfname1) {$foundDf1 = $true} Else {If ($_.DataFactoryName -eq $dfname2) {$foundDf2 = $true}}}
4341
Assert-True { $foundDf1 }
42+
Assert-True { $foundDf2 }
4443
}
4544
finally
4645
{
47-
Clean-DataFactory $rgname1 $dfname1
48-
Clean-DataFactory $rgname2 $dfname2
46+
CleanUp $rgname1 $dfname1
47+
CleanUp $rgname2 $dfname2
4948
}
5049
}
5150

5251
<#
5352
.SYNOPSIS
54-
Nagative test. Get resources from an non-existing empty group.
53+
Negative test. Tries to get a non-existing factory.
5554
#>
5655
function Test-GetNonExistingDataFactory
5756
{
@@ -61,14 +60,12 @@ function Test-GetNonExistingDataFactory
6160

6261
New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Force
6362

64-
# Test
6563
Assert-ThrowsContains { Get-AzureRmDataFactoryV2 -ResourceGroupName $rgname -Name $dfname } "NotFound"
6664
}
6765

6866
<#
6967
.SYNOPSIS
70-
Create a data factory and then do a Get to compare the result are identical.
71-
The datafactory will be removed when the test finishes.
68+
Creates a data factory and then does a Get to verify that both are identical.
7269
#>
7370
function Test-CreateDataFactory
7471
{
@@ -86,16 +83,17 @@ function Test-CreateDataFactory
8683

8784
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
8885
Assert-AreEqual $expected.DataFactoryName $actual.DataFactoryName
86+
Assert-AreEqual $expected.DataFactoryId $actual.DataFactoryId
8987
}
9088
finally
9189
{
92-
Clean-DataFactory $rgname $dfname
90+
CleanUp $rgname $dfname
9391
}
9492
}
9593

9694
<#
9795
.SYNOPSIS
98-
Create a data factory and then delete it with -DataFactory parameter.
96+
Creates a data factory and then deletes it with -InputObject parameter.
9997
#>
10098
function Test-DeleteDataFactoryWithDataFactoryParameter
10199
{
@@ -112,7 +110,7 @@ function Test-DeleteDataFactoryWithDataFactoryParameter
112110

113111
<#
114112
.SYNOPSIS
115-
Test piping support.
113+
Tests the piping support.
116114
#>
117115
function Test-DataFactoryPiping
118116
{
@@ -127,6 +125,24 @@ function Test-DataFactoryPiping
127125

128126
Get-AzureRmDataFactoryV2 -ResourceGroupName $rgname | Remove-AzureRmDataFactoryV2 -Force
129127

130-
# Test the data factory no longer exists
128+
# Verify the data factory no longer exists
131129
Assert-ThrowsContains { Get-AzureRmDataFactoryV2 -ResourceGroupName $rgname -Name $dfname } "NotFound"
132-
}
130+
}
131+
132+
<#
133+
.SYNOPSIS
134+
Tests that if the DataFactoryName is specified in Get-, the ResourceGroupName also must be specified.
135+
#>
136+
function Test-GetFactoryByNameParameterSet
137+
{
138+
$dfname = Get-DataFactoryName
139+
$rgname = Get-ResourceGroupName
140+
$rglocation = Get-ProviderLocation ResourceManagement
141+
$dflocation = Get-ProviderLocation DataFactoryManagement
142+
143+
New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Force
144+
145+
Set-AzureRmDataFactoryV2 -ResourceGroupName $rgname -Name $dfname -Location $dflocation -Force
146+
147+
Assert-ThrowsContains { Get-AzureRmDataFactoryV2 -DataFactoryName $dfname } "ResourceGroupName"
148+
}

0 commit comments

Comments
 (0)