Skip to content

Commit 6326806

Browse files
committed
Added commands for listing activity windows.
Help file update with the right information.
1 parent 5023f35 commit 6326806

13 files changed

+2221
-526
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6666
</Reference>
6767
<Reference Include="Microsoft.Azure.Management.DataFactories">
68-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.DataFactories.4.3.0\lib\net45\Microsoft.Azure.Management.DataFactories.dll</HintPath>
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.DataFactories.4.7.0\lib\net45\Microsoft.Azure.Management.DataFactories.dll</HintPath>
6969
</Reference>
7070
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7171
<SpecificVersion>False</SpecificVersion>
@@ -175,6 +175,7 @@
175175
</ItemGroup>
176176
<ItemGroup>
177177
<Compile Include="ScenarioTests\HubTests.cs" />
178+
<Compile Include="UnitTests\GetActivityWindowTests.cs" />
178179
<Compile Include="UnitTests\GetHubTests.cs" />
179180
<Compile Include="ScenarioTests\DataFactoryGatewayTests.cs" />
180181
<Compile Include="ScenarioTests\LinkedServiceTests.cs" />
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
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.DataFactories.Models;
16+
using Microsoft.Azure.Management.DataFactories.Models;
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using Moq;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Linq;
22+
using Xunit;
23+
24+
namespace Microsoft.Azure.Commands.DataFactories.Test.UnitTests
25+
{
26+
public class GetActivityWindowTests : DataFactoryUnitTestBase
27+
{
28+
private const string pipelineName = "pipeline";
29+
private const string datasetName = "dataset";
30+
private const string activityName = "activity";
31+
32+
private GetAzureDataFactoryActivityWindowsCommand cmdlet;
33+
34+
private List<PSActivityWindow> expectedDf;
35+
private ActivityWindowListResponse response;
36+
37+
// Arrange
38+
List<ActivityWindow> activityWindowsForResponseWindows = new List<ActivityWindow>()
39+
{
40+
new ActivityWindow()
41+
{
42+
PipelineName = pipelineName,
43+
DataFactoryName = DataFactoryName,
44+
ResourceGroupName = ResourceGroupName,
45+
LinkedServiceName = "ls",
46+
RunStart = new DateTime(2016, 10, 02),
47+
RunEnd = new DateTime(2016, 10, 03),
48+
PercentComplete = 90
49+
},
50+
new ActivityWindow()
51+
{
52+
PipelineName = pipelineName,
53+
DataFactoryName = DataFactoryName,
54+
ResourceGroupName = ResourceGroupName,
55+
LinkedServiceName = "ls2",
56+
RunStart = new DateTime(2016, 10, 02),
57+
RunEnd = new DateTime(2016, 10, 03),
58+
PercentComplete = 70
59+
}
60+
};
61+
62+
public GetActivityWindowTests(Xunit.Abstractions.ITestOutputHelper output)
63+
{
64+
Azure.ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new Azure.ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
65+
base.SetupTest();
66+
67+
this.expectedDf = new List<PSActivityWindow>();
68+
this.expectedDf.AddRange(activityWindowsForResponseWindows.Select(activityWindow => new PSActivityWindow(activityWindow)));
69+
70+
this.response = new ActivityWindowListResponse()
71+
{
72+
ActivityWindowListResponseValue = new ActivityWindowListResponseValue()
73+
{
74+
ActivityWindows = activityWindowsForResponseWindows,
75+
LastUpdate = DateTime.UtcNow.ToString()
76+
},
77+
NextLink = null
78+
};
79+
}
80+
81+
[Fact]
82+
[Trait(Category.AcceptanceType, Category.CheckIn)]
83+
public void CanListDataFactoryActivityWindows()
84+
{
85+
cmdlet = new GetAzureDataFactoryActivityWindowsCommand()
86+
{
87+
CommandRuntime = commandRuntimeMock.Object,
88+
DataFactoryClient = dataFactoriesClientMock.Object,
89+
ResourceGroupName = ResourceGroupName,
90+
DataFactoryName = DataFactoryName
91+
};
92+
93+
dataFactoriesClientMock
94+
.Setup(
95+
c =>
96+
c.ListByDataFactoryActivityWindows(It.IsAny<string>(),
97+
It.Is<ActivityWindowsByDataFactoryListParameters>(
98+
options =>
99+
options.ResourceGroupName == ResourceGroupName &&
100+
options.DataFactoryName == DataFactoryName)))
101+
.Returns(this.response)
102+
.Verifiable();
103+
104+
// Action
105+
cmdlet.ExecuteCmdlet();
106+
107+
// Assert
108+
dataFactoriesClientMock.VerifyAll();
109+
110+
commandRuntimeMock.Verify(f => f.WriteObject(It.Is<List<PSActivityWindow>>(x => this.ValidateResult(x)), true), Times.Once());
111+
}
112+
113+
[Fact]
114+
[Trait(Category.AcceptanceType, Category.CheckIn)]
115+
public void CanListPipelineActivityWindows()
116+
{
117+
cmdlet = new GetAzureDataFactoryActivityWindowsCommand()
118+
{
119+
CommandRuntime = commandRuntimeMock.Object,
120+
DataFactoryClient = dataFactoriesClientMock.Object,
121+
ResourceGroupName = ResourceGroupName,
122+
DataFactoryName = DataFactoryName,
123+
PipelineName = pipelineName
124+
};
125+
126+
dataFactoriesClientMock
127+
.Setup(
128+
c =>
129+
c.ListByPipelineActivityWindows(It.IsAny<string>(),
130+
It.Is<ActivityWindowsByPipelineListParameters>(
131+
options =>
132+
options.ResourceGroupName == ResourceGroupName &&
133+
options.DataFactoryName == DataFactoryName &&
134+
options.PipelineName == pipelineName)))
135+
.Returns(this.response)
136+
.Verifiable();
137+
138+
// Action
139+
cmdlet.ExecuteCmdlet();
140+
141+
// Assert
142+
dataFactoriesClientMock.VerifyAll();
143+
144+
commandRuntimeMock.Verify(f => f.WriteObject(It.Is<List<PSActivityWindow>>(x => this.ValidateResult(x)), true), Times.Once());
145+
}
146+
147+
[Fact]
148+
[Trait(Category.AcceptanceType, Category.CheckIn)]
149+
public void CanListDatasetActivityWindows()
150+
{
151+
cmdlet = new GetAzureDataFactoryActivityWindowsCommand()
152+
{
153+
CommandRuntime = commandRuntimeMock.Object,
154+
DataFactoryClient = dataFactoriesClientMock.Object,
155+
ResourceGroupName = ResourceGroupName,
156+
DataFactoryName = DataFactoryName,
157+
DatasetName = datasetName
158+
};
159+
160+
dataFactoriesClientMock
161+
.Setup(
162+
c =>
163+
c.ListByDatasetActivityWindows(It.IsAny<string>(),
164+
It.Is<ActivityWindowsByDatasetListParameters>(
165+
options =>
166+
options.ResourceGroupName == ResourceGroupName &&
167+
options.DataFactoryName == DataFactoryName &&
168+
options.DatasetName == datasetName)))
169+
.Returns(this.response)
170+
.Verifiable();
171+
172+
// Action
173+
cmdlet.ExecuteCmdlet();
174+
175+
// Assert
176+
dataFactoriesClientMock.VerifyAll();
177+
178+
commandRuntimeMock.Verify(f => f.WriteObject(It.Is<List<PSActivityWindow>>(x => this.ValidateResult(x)), true), Times.Once());
179+
}
180+
181+
[Fact]
182+
[Trait(Category.AcceptanceType, Category.CheckIn)]
183+
public void CanListActivityActivityWindows()
184+
{
185+
cmdlet = new GetAzureDataFactoryActivityWindowsCommand()
186+
{
187+
CommandRuntime = commandRuntimeMock.Object,
188+
DataFactoryClient = dataFactoriesClientMock.Object,
189+
ResourceGroupName = ResourceGroupName,
190+
DataFactoryName = DataFactoryName,
191+
PipelineName = pipelineName,
192+
ActivityName = activityName
193+
};
194+
195+
dataFactoriesClientMock
196+
.Setup(
197+
c =>
198+
c.ListByActivityActivityWindows(It.IsAny<string>(),
199+
It.Is<ActivityWindowsByActivityListParameters>(
200+
options =>
201+
options.ResourceGroupName == ResourceGroupName &&
202+
options.DataFactoryName == DataFactoryName &&
203+
options.PipelineName == pipelineName &&
204+
options.ActivityName == activityName)))
205+
.Returns(this.response)
206+
.Verifiable();
207+
208+
// Action
209+
cmdlet.ExecuteCmdlet();
210+
211+
// Assert
212+
dataFactoriesClientMock.VerifyAll();
213+
214+
commandRuntimeMock.Verify(f => f.WriteObject(It.Is<List<PSActivityWindow>>(x => this.ValidateResult(x)), true), Times.Once());
215+
}
216+
217+
[Fact]
218+
[Trait(Category.AcceptanceType, Category.CheckIn)]
219+
public void CanThrowWarningWhenBadArgumentPassed()
220+
{
221+
cmdlet = new GetAzureDataFactoryActivityWindowsCommand()
222+
{
223+
CommandRuntime = commandRuntimeMock.Object,
224+
DataFactoryClient = dataFactoriesClientMock.Object,
225+
ResourceGroupName = ResourceGroupName,
226+
DataFactoryName = DataFactoryName,
227+
DatasetName = datasetName,
228+
PipelineName = pipelineName,
229+
ActivityName = activityName
230+
};
231+
232+
// Action
233+
cmdlet.ExecuteCmdlet();
234+
235+
// Assert
236+
dataFactoriesClientMock.VerifyAll();
237+
238+
commandRuntimeMock.Verify(f => f.WriteWarning(It.Is<string>(x => x.Contains("An incorrect combination of arguments was passed"))), Times.Once());
239+
}
240+
241+
private bool ValidateResult(List<PSActivityWindow> result)
242+
{
243+
if (result.Count != expectedDf.Count)
244+
{
245+
return false;
246+
}
247+
248+
for (int i = 0; i < result.Count; i++)
249+
{
250+
if (!result[i].IsEqualTo(expectedDf[i]))
251+
{
252+
return false;
253+
}
254+
}
255+
256+
return true;
257+
}
258+
}
259+
}

src/ResourceManager/DataFactories/Commands.DataFactories.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
9-
<package id="Microsoft.Azure.Management.DataFactories" version="4.3.0" targetFramework="net45" />
9+
<package id="Microsoft.Azure.Management.DataFactories" version="4.7.0" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Test.Framework" version="1.0.6052.28118-prerelease" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Microsoft.Azure.Commands.DataFactories
17+
{
18+
public abstract class ActivityWindowContextBaseCmdlet : DataFactoryBaseCmdlet
19+
{
20+
}
21+
}

0 commit comments

Comments
 (0)