Skip to content

Commit 197c382

Browse files
committed
Merge pull request #39 from Azure/dev
.
2 parents 8d080eb + af8fdf9 commit 197c382

File tree

118 files changed

+8376
-4069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+8376
-4069
lines changed

src/ResourceManager/Automation/Commands.Automation.Test/Commands.ResourceManagement.Automation.Test.csproj

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ProjectGuid>{59D1B5DC-9175-43EC-90C6-CBA601B3565F}</ProjectGuid>
1010
<OutputType>Library</OutputType>
1111
<AppDesignerFolder>Properties</AppDesignerFolder>
12-
<RootNamespace>Microsoft.Azure.Commands.Automation.Test</RootNamespace>
12+
<RootNamespace>Microsoft.Azure.Commands.ResourceManager.Automation.Test</RootNamespace>
1313
<AssemblyName>Microsoft.Azure.Commands.ResourceManager.Automation.Test</AssemblyName>
1414
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1515
<FileAlignment>512</FileAlignment>
@@ -111,13 +111,43 @@
111111
</ItemGroup>
112112
<ItemGroup>
113113
<Compile Include="Properties\AssemblyInfo.cs" />
114+
<Compile Include="UnitTests\GetAzureAutomationCertificateTest.cs" />
115+
<Compile Include="UnitTests\GetAzureAutomationConnectionTest.cs" />
116+
<Compile Include="UnitTests\GetAzureAutomationCredentialTest.cs" />
117+
<Compile Include="UnitTests\GetAzureAutomationJobTest.cs" />
118+
<Compile Include="UnitTests\GetAzureAutomationRunbookTest.cs" />
119+
<Compile Include="UnitTests\GetAzureAutomationScheduledRunbookTest.cs" />
120+
<Compile Include="UnitTests\GetAzureAutomationScheduleTest.cs" />
121+
<Compile Include="UnitTests\GetAzureAutomationVariableTest.cs" />
114122
<Compile Include="UnitTests\GetAzureAutomationWebhookTest.cs" />
115123
<Compile Include="UnitTests\NewAzureAutomationAccountTest.cs" />
116124
<Compile Include="UnitTests\GetAzureAutomationAccountTest.cs" />
125+
<Compile Include="UnitTests\NewAzureAutomationCertificateTest.cs" />
126+
<Compile Include="UnitTests\NewAzureAutomationConnectionTest.cs" />
127+
<Compile Include="UnitTests\NewAzureAutomationCredentialTest.cs" />
128+
<Compile Include="UnitTests\NewAzureAutomationRunbookTest.cs" />
129+
<Compile Include="UnitTests\NewAzureAutomationScheduleTest.cs" />
130+
<Compile Include="UnitTests\NewAzureAutomationVariableTest.cs" />
117131
<Compile Include="UnitTests\NewAzureAutomationWebhookTest.cs" />
132+
<Compile Include="UnitTests\PublishAzureAutomationRunbookTest.cs" />
133+
<Compile Include="UnitTests\RegisterAzureAutomationScheduledRunbookTest.cs" />
118134
<Compile Include="UnitTests\RemoveAzureAutomationAccountTest.cs" />
135+
<Compile Include="UnitTests\RemoveAzureAutomationCertificateTest.cs" />
136+
<Compile Include="UnitTests\RemoveAzureAutomationConnectionTest.cs" />
137+
<Compile Include="UnitTests\RemoveAzureAutomationModuleTest.cs" />
138+
<Compile Include="UnitTests\RemoveAzureAutomationRunbookTest.cs" />
139+
<Compile Include="UnitTests\RemoveAzureAutomationScheduleTest.cs" />
140+
<Compile Include="UnitTests\RemoveAzureAutomationVariableTest.cs" />
119141
<Compile Include="UnitTests\RemoveAzureAutomationWebhookTest.cs" />
142+
<Compile Include="UnitTests\ResumeAzureAutomationJobTest.cs" />
143+
<Compile Include="UnitTests\SetAzureAutomationCredentialTest.cs" />
144+
<Compile Include="UnitTests\SetAzureAutomationRunbookTest.cs" />
145+
<Compile Include="UnitTests\SetAzureAutomationScheduleTest.cs" />
120146
<Compile Include="UnitTests\SetAzureAutomationWebhookTest.cs" />
147+
<Compile Include="UnitTests\StartAzureAutomationRunbookTest.cs" />
148+
<Compile Include="UnitTests\StopAzureAutomationJobTest.cs" />
149+
<Compile Include="UnitTests\SuspendAzureAutomationJobTest.cs" />
150+
<Compile Include="UnitTests\UnregisterAzureAutomationScheduledRunbookTest.cs" />
121151
</ItemGroup>
122152
<ItemGroup>
123153
<ProjectReference Include="..\..\..\Common\Commands.Common.Test\Commands.Common.Test.csproj">

src/ResourceManager/Automation/Commands.Automation.Test/UnitTests/GetAzureAutomationAccountTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2323
using Moq;
2424

25-
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
25+
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
2626
{
2727
[TestClass]
2828
public class GetAzureAutomationAccountTest : TestBase
@@ -55,6 +55,7 @@ public void GetAzureAutomationAllAccountsSuccessfull()
5555
this.mockAutomationClient.Setup(f => f.ListAutomationAccounts(resourceGroupName, ref nextLink)).Returns((string a, string b) => new List<AutomationAccount>());
5656

5757
// Test
58+
this.cmdlet.ResourceGroupName = resourceGroupName;
5859
this.cmdlet.ExecuteCmdlet();
5960

6061
// Assert
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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.ResourceManager.Automation.Test.UnitTests
27+
{
28+
[TestClass]
29+
public class GetAzureAutomationCertificateTest : TestBase
30+
{
31+
private Mock<IAutomationClient> mockAutomationClient;
32+
33+
private MockCommandRuntime mockCommandRuntime;
34+
35+
private GetAzureAutomationCertificate cmdlet;
36+
37+
[TestInitialize]
38+
public void SetupTest()
39+
{
40+
this.mockAutomationClient = new Mock<IAutomationClient>();
41+
this.mockCommandRuntime = new MockCommandRuntime();
42+
this.cmdlet = new GetAzureAutomationCertificate
43+
{
44+
AutomationClient = this.mockAutomationClient.Object,
45+
CommandRuntime = this.mockCommandRuntime
46+
};
47+
}
48+
49+
[TestMethod]
50+
public void GetAzureAutomationCertificateByNameSuccessfull()
51+
{
52+
// Setup
53+
string resourceGroupName = "resourceGroup";
54+
string accountName = "automation";
55+
string certificateName = "certificate";
56+
57+
this.mockAutomationClient.Setup(f => f.GetCertificate(resourceGroupName, accountName, certificateName));
58+
59+
// Test
60+
this.cmdlet.ResourceGroupName = resourceGroupName;
61+
this.cmdlet.AutomationAccountName = accountName;
62+
this.cmdlet.Name = certificateName;
63+
this.cmdlet.SetParameterSet("ByCertificateName");
64+
this.cmdlet.ExecuteCmdlet();
65+
66+
// Assert
67+
this.mockAutomationClient.Verify(f => f.GetCertificate(resourceGroupName, accountName, certificateName), Times.Once());
68+
}
69+
70+
[TestMethod]
71+
public void GetAzureAutomationCertificateByAllSuccessfull()
72+
{
73+
// Setup
74+
string resourceGroupName = "resourceGroup";
75+
string accountName = "automation";
76+
string nextLink = string.Empty;
77+
78+
this.mockAutomationClient.Setup(f => f.ListCertificates(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<CertificateInfo>());
79+
80+
// Test
81+
this.cmdlet.ResourceGroupName = resourceGroupName;
82+
this.cmdlet.AutomationAccountName = accountName;
83+
this.cmdlet.ExecuteCmdlet();
84+
85+
// Assert
86+
this.mockAutomationClient.Verify(f => f.ListCertificates(resourceGroupName, accountName, ref nextLink), Times.Once());
87+
}
88+
}
89+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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.ResourceManager.Automation.Test.UnitTests
27+
{
28+
[TestClass]
29+
public class GetAzureAutomationConnectionTest : TestBase
30+
{
31+
private Mock<IAutomationClient> mockAutomationClient;
32+
33+
private MockCommandRuntime mockCommandRuntime;
34+
35+
private GetAzureAutomationConnection cmdlet;
36+
37+
[TestInitialize]
38+
public void SetupTest()
39+
{
40+
this.mockAutomationClient = new Mock<IAutomationClient>();
41+
this.mockCommandRuntime = new MockCommandRuntime();
42+
this.cmdlet = new GetAzureAutomationConnection
43+
{
44+
AutomationClient = this.mockAutomationClient.Object,
45+
CommandRuntime = this.mockCommandRuntime
46+
};
47+
}
48+
49+
[TestMethod]
50+
public void GetAzureAutomationConnectionByNameSuccessfull()
51+
{
52+
// Setup
53+
string resourceGroupName = "resourceGroup";
54+
string accountName = "automation";
55+
string connectionName = "connection";
56+
57+
this.mockAutomationClient.Setup(f => f.GetConnection(resourceGroupName, accountName, connectionName));
58+
59+
// Test
60+
this.cmdlet.ResourceGroupName = resourceGroupName;
61+
this.cmdlet.AutomationAccountName = accountName;
62+
this.cmdlet.Name = connectionName;
63+
this.cmdlet.SetParameterSet("ByConnectionName");
64+
this.cmdlet.ExecuteCmdlet();
65+
66+
// Assert
67+
this.mockAutomationClient.Verify(f => f.GetConnection(resourceGroupName, accountName, connectionName), Times.Once());
68+
}
69+
70+
[TestMethod]
71+
public void GetAzureAutomationConnectionByAllSuccessfull()
72+
{
73+
// Setup
74+
string resourceGroupName = "resourceGroup";
75+
string accountName = "automation";
76+
string nextLink = string.Empty;
77+
78+
this.mockAutomationClient.Setup(f => f.ListConnections(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<Connection>());
79+
80+
// Test
81+
this.cmdlet.ResourceGroupName = resourceGroupName;
82+
this.cmdlet.AutomationAccountName = accountName;
83+
this.cmdlet.ExecuteCmdlet();
84+
85+
// Assert
86+
this.mockAutomationClient.Verify(f => f.ListConnections(resourceGroupName, accountName, ref nextLink), Times.Once());
87+
}
88+
89+
[TestMethod]
90+
public void GetAzureAutomationConnectionByTypeSuccessfull()
91+
{
92+
// Setup
93+
string resourceGroupName = "resourceGroup";
94+
string accountName = "automation";
95+
string connectionTypeName = "connectionType";
96+
97+
this.mockAutomationClient.Setup(f => f.ListConnectionsByType(resourceGroupName, accountName, connectionTypeName)).Returns((string a, string b, string c) => new List<Connection>());
98+
99+
// Test
100+
this.cmdlet.ResourceGroupName = resourceGroupName;
101+
this.cmdlet.AutomationAccountName = accountName;
102+
this.cmdlet.ConnectionTypeName = connectionTypeName;
103+
this.cmdlet.SetParameterSet("ByConnectionTypeName");
104+
this.cmdlet.ExecuteCmdlet();
105+
106+
// Assert
107+
this.mockAutomationClient.Verify(f => f.ListConnectionsByType(resourceGroupName, accountName, connectionTypeName), Times.Once());
108+
}
109+
}
110+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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.ResourceManager.Automation.Test.UnitTests
26+
{
27+
[TestClass]
28+
public class GetAzureAutomationCredentialTest : TestBase
29+
{
30+
private Mock<IAutomationClient> mockAutomationClient;
31+
32+
private MockCommandRuntime mockCommandRuntime;
33+
34+
private GetAzureAutomationCredential cmdlet;
35+
36+
[TestInitialize]
37+
public void SetupTest()
38+
{
39+
this.mockAutomationClient = new Mock<IAutomationClient>();
40+
this.mockCommandRuntime = new MockCommandRuntime();
41+
this.cmdlet = new GetAzureAutomationCredential
42+
{
43+
AutomationClient = this.mockAutomationClient.Object,
44+
CommandRuntime = this.mockCommandRuntime
45+
};
46+
}
47+
48+
[TestMethod]
49+
public void GetAzureAutomationCredentialByNameSuccessfull()
50+
{
51+
// Setup
52+
string resourceGroupName = "resourceGroup";
53+
string accountName = "automation";
54+
string credentialName = "credential";
55+
56+
this.mockAutomationClient.Setup(f => f.GetCredential(resourceGroupName, accountName, credentialName));
57+
58+
// Test
59+
this.cmdlet.ResourceGroupName = resourceGroupName;
60+
this.cmdlet.AutomationAccountName = accountName;
61+
this.cmdlet.Name = credentialName;
62+
this.cmdlet.ExecuteCmdlet();
63+
64+
// Assert
65+
this.mockAutomationClient.Verify(f => f.GetCredential(resourceGroupName, accountName, credentialName), Times.Once());
66+
}
67+
68+
[TestMethod]
69+
public void GetAzureAutomationCredentialByAllSuccessfull()
70+
{
71+
// Setup
72+
string resourceGroupName = "resourceGroup";
73+
string accountName = "automation";
74+
string nextLink = string.Empty;
75+
76+
this.mockAutomationClient.Setup(f => f.ListCredentials(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<CredentialInfo>());
77+
78+
// Test
79+
this.cmdlet.ResourceGroupName = resourceGroupName;
80+
this.cmdlet.AutomationAccountName = accountName;
81+
this.cmdlet.ExecuteCmdlet();
82+
83+
// Assert
84+
this.mockAutomationClient.Verify(f => f.ListCredentials(resourceGroupName, accountName, ref nextLink), Times.Once());
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)