Skip to content

Commit db080d8

Browse files
committed
merge with mpenta
2 parents 2b550ec + fa06234 commit db080d8

14 files changed

+526
-78
lines changed

src/ServiceManagement/Automation/Commands.Automation.Test/Commands.Automation.Test.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,22 @@
9393
<ItemGroup>
9494
<Compile Include="Properties\AssemblyInfo.cs" />
9595
<Compile Include="UnitTests\GetAzureAutomationCredentialTest.cs" />
96+
<Compile Include="UnitTests\GetAzureAutomationJobTest.cs" />
9697
<Compile Include="UnitTests\GetAzureAutomationModuleTest.cs" />
9798
<Compile Include="UnitTests\GetAzureAutomationScheduleTest.cs" />
9899
<Compile Include="UnitTests\NewAzureAutomationCredentialTest.cs" />
99100
<Compile Include="UnitTests\NewAzureAutomationModuleTest.cs" />
100101
<Compile Include="UnitTests\NewAzureAutomationScheduleTest.cs" />
101102
<Compile Include="UnitTests\NewAzureAutomationVariableTest.cs" />
102-
<Compile Include="UnitTests\RemoveAzureAutomationCredentialTest.cs" />
103103
<Compile Include="UnitTests\RemoveAzureAutomationModuleTest.cs" />
104104
<Compile Include="UnitTests\RemoveAzureAutomationScheduleTest.cs" />
105105
<Compile Include="UnitTests\RemoveAzureAutomationVariableTest.cs" />
106+
<Compile Include="UnitTests\GetAzureAutomationVariableTest.cs" />
107+
<Compile Include="UnitTests\ResumeAzureAutomationJobTest.cs" />
106108
<Compile Include="UnitTests\SetAzureAutomationCredentialTest.cs" />
107109
<Compile Include="UnitTests\SetAzureAutomationScheduleTest.cs" />
108-
<Compile Include="UnitTests\GetAzureAutomationVariableTest.cs" />
110+
<Compile Include="UnitTests\StopAzureAutomationJobTest.cs" />
111+
<Compile Include="UnitTests\SuspendAzureAutomationJobTest.cs" />
109112
</ItemGroup>
110113
<ItemGroup>
111114
<ProjectReference Include="..\..\..\Common\Commands.Common.Test\Commands.Common.Test.csproj">
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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 System;
16+
using System.Collections.Generic;
17+
using Microsoft.Azure.Commands.Automation.Cmdlet;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.VisualStudio.TestTools.UnitTesting;
21+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
22+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
23+
using Moq;
24+
25+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
26+
{
27+
[TestClass]
28+
public class GetAzureAutomationJobTest : TestBase
29+
{
30+
private Mock<IAutomationClient> mockAutomationClient;
31+
32+
private MockCommandRuntime mockCommandRuntime;
33+
34+
private GetAzureAutomationJob cmdlet;
35+
36+
[TestInitialize]
37+
public void SetupTest()
38+
{
39+
this.mockAutomationClient = new Mock<IAutomationClient>();
40+
this.mockCommandRuntime = new MockCommandRuntime();
41+
this.cmdlet = new GetAzureAutomationJob
42+
{
43+
AutomationClient = this.mockAutomationClient.Object,
44+
CommandRuntime = this.mockCommandRuntime
45+
};
46+
}
47+
48+
[TestMethod]
49+
public void GetAzureAutomationJobByRunbookNameSuccessfull()
50+
{
51+
// Setup
52+
string accountName = "automation";
53+
string runbookName = "runbook";
54+
55+
this.mockAutomationClient.Setup(f => f.ListJobsByRunbookName(accountName, runbookName, null, null));
56+
57+
// Test
58+
this.cmdlet.AutomationAccountName = accountName;
59+
this.cmdlet.RunbookName = runbookName;
60+
this.cmdlet.ExecuteCmdlet();
61+
62+
// Assert
63+
this.mockAutomationClient.Verify(f => f.ListJobsByRunbookName(accountName, runbookName, null, null), Times.Once());
64+
}
65+
66+
public void GetAzureAutomationJobByRunbookNamAndStartTimeEndTimeeSuccessfull()
67+
{
68+
// Setup
69+
string accountName = "automation";
70+
string runbookName = "runbook";
71+
DateTime startTime = new DateTime(2014, 12, 30, 17, 0, 0, 0);
72+
DateTime endTime = new DateTime(2014, 12, 30, 18, 0, 0, 0);
73+
74+
this.mockAutomationClient.Setup(f => f.ListJobsByRunbookName(accountName, runbookName, startTime, endTime));
75+
76+
// Test
77+
this.cmdlet.AutomationAccountName = accountName;
78+
this.cmdlet.RunbookName = runbookName;
79+
this.cmdlet.ExecuteCmdlet();
80+
81+
// Assert
82+
this.mockAutomationClient.Verify(f => f.ListJobsByRunbookName(accountName, runbookName, startTime, endTime), Times.Once());
83+
}
84+
85+
[TestMethod]
86+
public void GetAzureAutomationAllJobsSuccessfull()
87+
{
88+
// Setup
89+
string accountName = "automation";
90+
91+
this.mockAutomationClient.Setup(f => f.ListJobs(accountName, null, null));
92+
93+
// Test
94+
this.cmdlet.AutomationAccountName = accountName;
95+
this.cmdlet.ExecuteCmdlet();
96+
97+
// Assert
98+
this.mockAutomationClient.Verify(f => f.ListJobs(accountName, null, null), Times.Once());
99+
}
100+
101+
[TestMethod]
102+
public void GetAzureAutomationAllJobsBetweenStartAndEndTimeSuccessfull()
103+
{
104+
// Setup
105+
string accountName = "automation";
106+
DateTime startTime = new DateTime(2014, 12, 30, 17, 0, 0, 0);
107+
DateTime endTime = new DateTime(2014, 12, 30, 18, 0, 0, 0);
108+
109+
// look for jobs between 5pm to 6pm on 30th december 2014
110+
this.mockAutomationClient.Setup(f => f.ListJobs(accountName, startTime, endTime));
111+
112+
// Test
113+
this.cmdlet.AutomationAccountName = accountName;
114+
this.cmdlet.StartTime = startTime;
115+
this.cmdlet.EndTime = endTime;
116+
this.cmdlet.ExecuteCmdlet();
117+
118+
// Assert
119+
this.mockAutomationClient.Verify(f => f.ListJobs(accountName, startTime, endTime), Times.Once());
120+
}
121+
122+
public void GetAzureAutomationJobByIdSuccessfull()
123+
{
124+
// Setup
125+
string accountName = "automation";
126+
Guid jobId = Guid.NewGuid();
127+
128+
// look for jobs between 5pm to 6pm on 30th december 2014
129+
this.mockAutomationClient.Setup(f => f.GetJob(accountName, jobId));
130+
131+
// Test
132+
this.cmdlet.AutomationAccountName = accountName;
133+
this.cmdlet.Id = jobId;
134+
this.cmdlet.ExecuteCmdlet();
135+
136+
// Assert
137+
this.mockAutomationClient.Verify(f => f.GetJob(accountName, jobId), Times.Once());
138+
}
139+
}
140+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 System;
16+
using System.Collections.Generic;
17+
using Microsoft.Azure.Commands.Automation.Cmdlet;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.VisualStudio.TestTools.UnitTesting;
21+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
22+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
23+
using Moq;
24+
25+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
26+
{
27+
[TestClass]
28+
public class ResumeAzureAutomationJobTest : TestBase
29+
{
30+
private Mock<IAutomationClient> mockAutomationClient;
31+
32+
private MockCommandRuntime mockCommandRuntime;
33+
34+
private ResumeAzureAutomationJob cmdlet;
35+
36+
[TestInitialize]
37+
public void SetupTest()
38+
{
39+
this.mockAutomationClient = new Mock<IAutomationClient>();
40+
this.mockCommandRuntime = new MockCommandRuntime();
41+
this.cmdlet = new ResumeAzureAutomationJob
42+
{
43+
AutomationClient = this.mockAutomationClient.Object,
44+
CommandRuntime = this.mockCommandRuntime
45+
};
46+
}
47+
48+
[TestMethod]
49+
public void ResumeAzureAutomationJobSuccessfull()
50+
{
51+
// Setup
52+
string accountName = "automation";
53+
Guid jobId = Guid.NewGuid();
54+
55+
this.mockAutomationClient.Setup(f => f.ResumeJob(accountName, jobId));
56+
57+
// Test
58+
this.cmdlet.AutomationAccountName = accountName;
59+
this.cmdlet.Id = jobId;
60+
this.cmdlet.ExecuteCmdlet();
61+
62+
// Assert
63+
this.mockAutomationClient.Verify(f => f.ResumeJob(accountName, jobId), Times.Once());
64+
}
65+
}
66+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 System;
16+
using System.Collections.Generic;
17+
using Microsoft.Azure.Commands.Automation.Cmdlet;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.VisualStudio.TestTools.UnitTesting;
21+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
22+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
23+
using Moq;
24+
25+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
26+
{
27+
[TestClass]
28+
public class StopAzureAutomationJobTest : TestBase
29+
{
30+
private Mock<IAutomationClient> mockAutomationClient;
31+
32+
private MockCommandRuntime mockCommandRuntime;
33+
34+
private StopAzureAutomationJob cmdlet;
35+
36+
[TestInitialize]
37+
public void SetupTest()
38+
{
39+
this.mockAutomationClient = new Mock<IAutomationClient>();
40+
this.mockCommandRuntime = new MockCommandRuntime();
41+
this.cmdlet = new StopAzureAutomationJob
42+
{
43+
AutomationClient = this.mockAutomationClient.Object,
44+
CommandRuntime = this.mockCommandRuntime
45+
};
46+
}
47+
48+
[TestMethod]
49+
public void StopAzureAutomationJobSuccessfull()
50+
{
51+
// Setup
52+
string accountName = "automation";
53+
Guid jobId = Guid.NewGuid();
54+
55+
this.mockAutomationClient.Setup(f => f.StopJob(accountName, jobId));
56+
57+
// Test
58+
this.cmdlet.AutomationAccountName = accountName;
59+
this.cmdlet.Id = jobId;
60+
this.cmdlet.ExecuteCmdlet();
61+
62+
// Assert
63+
this.mockAutomationClient.Verify(f => f.StopJob(accountName, jobId), Times.Once());
64+
}
65+
}
66+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 System;
16+
using System.Collections.Generic;
17+
using Microsoft.Azure.Commands.Automation.Cmdlet;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.VisualStudio.TestTools.UnitTesting;
21+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
22+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
23+
using Moq;
24+
25+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
26+
{
27+
[TestClass]
28+
public class SuspendAzureAutomationJobTest : TestBase
29+
{
30+
private Mock<IAutomationClient> mockAutomationClient;
31+
32+
private MockCommandRuntime mockCommandRuntime;
33+
34+
private SuspendAzureAutomationJob cmdlet;
35+
36+
[TestInitialize]
37+
public void SetupTest()
38+
{
39+
this.mockAutomationClient = new Mock<IAutomationClient>();
40+
this.mockCommandRuntime = new MockCommandRuntime();
41+
this.cmdlet = new SuspendAzureAutomationJob
42+
{
43+
AutomationClient = this.mockAutomationClient.Object,
44+
CommandRuntime = this.mockCommandRuntime
45+
};
46+
}
47+
48+
[TestMethod]
49+
public void SuspendAzureAutomationJobSuccessfull()
50+
{
51+
// Setup
52+
string accountName = "automation";
53+
Guid jobId = Guid.NewGuid();
54+
55+
this.mockAutomationClient.Setup(f => f.SuspendJob(accountName, jobId));
56+
57+
// Test
58+
this.cmdlet.AutomationAccountName = accountName;
59+
this.cmdlet.Id = jobId;
60+
this.cmdlet.ExecuteCmdlet();
61+
62+
// Assert
63+
this.mockAutomationClient.Verify(f => f.SuspendJob(accountName, jobId), Times.Once());
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)