Skip to content

Commit 0078dbf

Browse files
committed
merged with mpenta and elvg - the unit test project has been disabled to due compile issues.. need to pull from mpenta
2 parents db080d8 + 49d22b8 commit 0078dbf

40 files changed

+2900
-209
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@
9292
</ItemGroup>
9393
<ItemGroup>
9494
<Compile Include="Properties\AssemblyInfo.cs" />
95+
<Compile Include="UnitTests\GetAzureAutomationRunbookDefinitionTest.cs" />
96+
<Compile Include="UnitTests\GetAzureAutomationRunbookTest.cs" />
97+
<Compile Include="UnitTests\GetAzureAutomationScheduledRunbookTest.cs" />
98+
<Compile Include="UnitTests\NewAzureAutomationRunbookTest.cs" />
99+
<Compile Include="UnitTests\PublishAzureAutomationRunbookTest.cs" />
100+
<Compile Include="UnitTests\RegisterAzureAutomationScheduledRunbook.cs" />
101+
<Compile Include="UnitTests\RemoveAzureAutomationRunbookTest.cs" />
102+
<Compile Include="UnitTests\SetAzureAutomationRunbookDefinitionTest.cs" />
103+
<Compile Include="UnitTests\SetAzureAutomationRunbookTest.cs" />
95104
<Compile Include="UnitTests\GetAzureAutomationCredentialTest.cs" />
96105
<Compile Include="UnitTests\GetAzureAutomationJobTest.cs" />
97106
<Compile Include="UnitTests\GetAzureAutomationModuleTest.cs" />
@@ -107,8 +116,13 @@
107116
<Compile Include="UnitTests\ResumeAzureAutomationJobTest.cs" />
108117
<Compile Include="UnitTests\SetAzureAutomationCredentialTest.cs" />
109118
<Compile Include="UnitTests\SetAzureAutomationScheduleTest.cs" />
119+
<<<<<<< HEAD
110120
<Compile Include="UnitTests\StopAzureAutomationJobTest.cs" />
111121
<Compile Include="UnitTests\SuspendAzureAutomationJobTest.cs" />
122+
=======
123+
<Compile Include="UnitTests\GetAzureAutomationVariableTest.cs" />
124+
<Compile Include="UnitTests\StartAzureAutomationRunbookTest.cs" />
125+
>>>>>>> 49d22b83a8c84569821f203c51e06464d41a95da
112126
</ItemGroup>
113127
<ItemGroup>
114128
<ProjectReference Include="..\..\..\Common\Commands.Common.Test\Commands.Common.Test.csproj">
@@ -127,6 +141,7 @@
127141
<ItemGroup>
128142
<None Include="MSSharedLibKey.snk" />
129143
<None Include="packages.config" />
144+
<Compile Include="UnitTests\UnregisterAzureAutomationScheduledRunbook.cs" />
130145
</ItemGroup>
131146
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
132147
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 Microsoft.Azure.Commands.Automation.Cmdlet;
17+
using Microsoft.Azure.Commands.Automation.Common;
18+
using Microsoft.VisualStudio.TestTools.UnitTesting;
19+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
20+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
21+
using Moq;
22+
23+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
24+
{
25+
[TestClass]
26+
public class GetAzureAutomationRunbookDefinitionTest : TestBase
27+
{
28+
private Mock<IAutomationClient> mockAutomationClient;
29+
30+
private MockCommandRuntime mockCommandRuntime;
31+
32+
private GetAzureAutomationRunbookDefinition cmdlet;
33+
34+
[TestInitialize]
35+
public void SetupTest()
36+
{
37+
this.mockAutomationClient = new Mock<IAutomationClient>();
38+
this.mockCommandRuntime = new MockCommandRuntime();
39+
this.cmdlet = new GetAzureAutomationRunbookDefinition
40+
{
41+
AutomationClient = this.mockAutomationClient.Object,
42+
CommandRuntime = this.mockCommandRuntime
43+
};
44+
}
45+
46+
[TestMethod]
47+
public void GetAzureAutomationRunbookDefinitionByRunbookNameWithoutSlotSuccessfull()
48+
{
49+
// Setup
50+
string accountName = "automation";
51+
string runbookName = "runbook";
52+
53+
this.mockAutomationClient.Setup(f => f.ListRunbookDefinitionsByRunbookName(accountName, runbookName, null));
54+
55+
// Test
56+
this.cmdlet.AutomationAccountName = accountName;
57+
this.cmdlet.Name = runbookName;
58+
this.cmdlet.ExecuteCmdlet();
59+
60+
// Assert
61+
this.mockAutomationClient.Verify(f => f.ListRunbookDefinitionsByRunbookName(accountName, runbookName, null), Times.Once());
62+
}
63+
64+
[TestMethod]
65+
public void GetAzureAutomationRunbookDefinitionByRunbookNameSlotPublishedSuccessfull()
66+
{
67+
// Setup
68+
string accountName = "automation";
69+
string runbookName = "runbook";
70+
71+
this.mockAutomationClient.Setup(f => f.ListRunbookDefinitionsByRunbookName(accountName, runbookName, false));
72+
73+
// Test
74+
this.cmdlet.AutomationAccountName = accountName;
75+
this.cmdlet.Name = runbookName;
76+
this.cmdlet.Slot = "Published";
77+
this.cmdlet.ExecuteCmdlet();
78+
79+
// Assert
80+
this.mockAutomationClient.Verify(f => f.ListRunbookDefinitionsByRunbookName(accountName, runbookName, false), Times.Once());
81+
}
82+
}
83+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
using Moq;
25+
26+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
27+
{
28+
[TestClass]
29+
public class GetAzureAutomationRunbookTest : TestBase
30+
{
31+
private Mock<IAutomationClient> mockAutomationClient;
32+
33+
private MockCommandRuntime mockCommandRuntime;
34+
35+
private GetAzureAutomationRunbook cmdlet;
36+
37+
[TestInitialize]
38+
public void SetupTest()
39+
{
40+
this.mockAutomationClient = new Mock<IAutomationClient>();
41+
this.mockCommandRuntime = new MockCommandRuntime();
42+
this.cmdlet = new GetAzureAutomationRunbook
43+
{
44+
AutomationClient = this.mockAutomationClient.Object,
45+
CommandRuntime = this.mockCommandRuntime
46+
};
47+
}
48+
49+
[TestMethod]
50+
public void GetAzureAutomationRunbookByNameSuccessfull()
51+
{
52+
// Setup
53+
string accountName = "automation";
54+
string runbookName = "runbook";
55+
56+
this.mockAutomationClient.Setup(f => f.GetRunbook(accountName, runbookName));
57+
58+
// Test
59+
this.cmdlet.AutomationAccountName = accountName;
60+
this.cmdlet.Name = runbookName;
61+
this.cmdlet.SetParameterSet("ByName");
62+
this.cmdlet.ExecuteCmdlet();
63+
64+
// Assert
65+
this.mockAutomationClient.Verify(f => f.GetRunbook(accountName, runbookName), Times.Once());
66+
}
67+
68+
[TestMethod]
69+
public void GetAzureAutomationRunbookByAllSuccessfull()
70+
{
71+
// Setup
72+
string accountName = "automation";
73+
74+
this.mockAutomationClient.Setup(f => f.ListRunbooks(accountName)).Returns((string a) => new List<Runbook>()); ;
75+
76+
// Test
77+
this.cmdlet.AutomationAccountName = accountName;
78+
this.cmdlet.SetParameterSet("ByAll");
79+
this.cmdlet.ExecuteCmdlet();
80+
81+
// Assert
82+
this.mockAutomationClient.Verify(f => f.ListRunbooks(accountName), Times.Once());
83+
}
84+
}
85+
}

src/ServiceManagement/Automation/Commands.Automation.Test/UnitTests/GetAzureAutomationScheduleTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Microsoft.VisualStudio.TestTools.UnitTesting;
2121
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
2222
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
23+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2324
using Moq;
2425

2526
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
@@ -57,6 +58,7 @@ public void GetAzureAutomationScheduleByNameSuccessfull()
5758
// Test
5859
this.cmdlet.AutomationAccountName = accountName;
5960
this.cmdlet.Name = scheduleName;
61+
this.cmdlet.SetParameterSet(AutomationCmdletParameterSets.ByName);
6062
this.cmdlet.ExecuteCmdlet();
6163

6264
// Assert
@@ -73,6 +75,7 @@ public void GetAzureAutomationScheduleByAllSuccessfull()
7375

7476
// Test
7577
this.cmdlet.AutomationAccountName = accountName;
78+
this.cmdlet.SetParameterSet(AutomationCmdletParameterSets.ByAll);
7679
this.cmdlet.ExecuteCmdlet();
7780

7881
// Assert
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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 Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
using Moq;
25+
26+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
27+
{
28+
[TestClass]
29+
public class GetAzureAutomationScheduledRunbookTest : TestBase
30+
{
31+
private Mock<IAutomationClient> mockAutomationClient;
32+
33+
private MockCommandRuntime mockCommandRuntime;
34+
35+
private GetAzureAutomationScheduledRunbook cmdlet;
36+
37+
[TestInitialize]
38+
public void SetupTest()
39+
{
40+
this.mockAutomationClient = new Mock<IAutomationClient>();
41+
this.mockCommandRuntime = new MockCommandRuntime();
42+
this.cmdlet = new GetAzureAutomationScheduledRunbook
43+
{
44+
AutomationClient = this.mockAutomationClient.Object,
45+
CommandRuntime = this.mockCommandRuntime
46+
};
47+
}
48+
49+
[TestMethod]
50+
public void GetAzureAutomationScheduledRunbookByIdSuccessfull()
51+
{
52+
// Setup
53+
string accountName = "automation";
54+
var jobScheduleId = new Guid();
55+
56+
this.mockAutomationClient.Setup(f => f.GetJobSchedule(accountName, jobScheduleId));
57+
58+
// Test
59+
this.cmdlet.AutomationAccountName = accountName;
60+
this.cmdlet.Id = jobScheduleId;
61+
this.cmdlet.SetParameterSet(AutomationCmdletParameterSets.ByJobScheduleId);
62+
this.cmdlet.ExecuteCmdlet();
63+
64+
// Assert
65+
this.mockAutomationClient.Verify(f => f.GetJobSchedule(accountName, jobScheduleId), Times.Once());
66+
}
67+
68+
[TestMethod]
69+
public void GetAzureAutomationScheduledRunbookByrunbookNameAndScheduleNameSuccessfull()
70+
{
71+
// Setup
72+
string accountName = "automation";
73+
string runbookName = "runbook";
74+
string scheduleName = "schedule";
75+
76+
this.mockAutomationClient.Setup(f => f.GetJobSchedule(accountName, runbookName, scheduleName));
77+
78+
// Test
79+
this.cmdlet.AutomationAccountName = accountName;
80+
this.cmdlet.RunbookName = runbookName;
81+
this.cmdlet.ScheduleName = scheduleName;
82+
this.cmdlet.SetParameterSet(AutomationCmdletParameterSets.ByRunbookNameAndScheduleName);
83+
this.cmdlet.ExecuteCmdlet();
84+
85+
// Assert
86+
this.mockAutomationClient.Verify(f => f.GetJobSchedule(accountName, runbookName, scheduleName), Times.Once());
87+
}
88+
89+
[TestMethod]
90+
public void GetAzureAutomationScheduledRunbookByRunbookNameSuccessfull()
91+
{
92+
// Setup
93+
string accountName = "automation";
94+
string runbookName = "runbook";
95+
96+
this.mockAutomationClient.Setup(f => f.ListJobSchedulesByRunbookName(accountName, runbookName)).Returns((string a, string b) => new List<JobSchedule>());
97+
98+
// Test
99+
this.cmdlet.AutomationAccountName = accountName;
100+
this.cmdlet.RunbookName = runbookName;
101+
this.cmdlet.SetParameterSet(AutomationCmdletParameterSets.ByRunbookName);
102+
this.cmdlet.ExecuteCmdlet();
103+
104+
// Assert
105+
this.mockAutomationClient.Verify(f => f.ListJobSchedulesByRunbookName(accountName, runbookName), Times.Once());
106+
}
107+
108+
[TestMethod]
109+
public void GetAzureAutomationScheduledRunbookByScheduleNameSuccessfull()
110+
{
111+
// Setup
112+
string accountName = "automation";
113+
string scheduleName = "schedule";
114+
115+
this.mockAutomationClient.Setup(f => f.ListJobSchedulesByScheduleName(accountName, scheduleName)).Returns((string a, string b) => new List<JobSchedule>());
116+
117+
// Test
118+
this.cmdlet.AutomationAccountName = accountName;
119+
this.cmdlet.ScheduleName = scheduleName;
120+
this.cmdlet.SetParameterSet(AutomationCmdletParameterSets.ByScheduleName);
121+
this.cmdlet.ExecuteCmdlet();
122+
123+
// Assert
124+
this.mockAutomationClient.Verify(f => f.ListJobSchedulesByScheduleName(accountName, scheduleName), Times.Once());
125+
}
126+
127+
[TestMethod]
128+
public void GetAzureAutomationScheduledRunbookByAllSuccessfull()
129+
{
130+
// Setup
131+
string accountName = "automation";
132+
133+
this.mockAutomationClient.Setup(f => f.ListJobSchedules(accountName)).Returns((string a) => new List<JobSchedule>());
134+
135+
// Test
136+
this.cmdlet.AutomationAccountName = accountName;
137+
this.cmdlet.SetParameterSet(AutomationCmdletParameterSets.ByAll);
138+
this.cmdlet.ExecuteCmdlet();
139+
140+
// Assert
141+
this.mockAutomationClient.Verify(f => f.ListJobSchedules(accountName), Times.Once());
142+
}
143+
}
144+
}

0 commit comments

Comments
 (0)