Skip to content

Commit a9d7cc1

Browse files
committed
Merge pull request #11 from Azure/dev
.
2 parents 39ef2e1 + e073bb8 commit a9d7cc1

File tree

60 files changed

+3926
-2469
lines changed

Some content is hidden

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

60 files changed

+3926
-2469
lines changed

setup/azurecmdfiles.wxi

Lines changed: 0 additions & 336 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@
111111
</ItemGroup>
112112
<ItemGroup>
113113
<Compile Include="Properties\AssemblyInfo.cs" />
114+
<Compile Include="UnitTests\GetAzureAutomationWebhookTest.cs" />
114115
<Compile Include="UnitTests\NewAzureAutomationAccountTest.cs" />
115116
<Compile Include="UnitTests\GetAzureAutomationAccountTest.cs" />
117+
<Compile Include="UnitTests\NewAzureAutomationWebhookTest.cs" />
116118
<Compile Include="UnitTests\RemoveAzureAutomationAccountTest.cs" />
119+
<Compile Include="UnitTests\RemoveAzureAutomationWebhookTest.cs" />
120+
<Compile Include="UnitTests\SetAzureAutomationWebhookTest.cs" />
117121
</ItemGroup>
118122
<ItemGroup>
119123
<ProjectReference Include="..\..\..\Common\Commands.Common.Test\Commands.Common.Test.csproj">

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ public void GetAzureAutomationAllAccountsSuccessfull()
5050
{
5151
// Setup
5252
string resourceGroupName = "resourceGroup";
53+
string nextLink = string.Empty;
5354

54-
this.mockAutomationClient.Setup(f => f.ListAutomationAccounts(resourceGroupName)).Returns((string a) => new List<AutomationAccount>());
55+
this.mockAutomationClient.Setup(f => f.ListAutomationAccounts(resourceGroupName, ref nextLink)).Returns((string a, string b) => new List<AutomationAccount>());
5556

5657
// Test
5758
this.cmdlet.ExecuteCmdlet();
5859

5960
// Assert
60-
this.mockAutomationClient.Verify(f => f.ListAutomationAccounts(null), Times.Once());
61+
this.mockAutomationClient.Verify(f => f.ListAutomationAccounts(resourceGroupName, ref nextLink), Times.Once());
6162
}
6263

6364
[TestMethod]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.VisualStudio.TestTools.UnitTesting;
18+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
using Moq;
22+
23+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
24+
{
25+
[TestClass]
26+
public class GetAzureAutomationWebhookTest : TestBase
27+
{
28+
private Mock<IAutomationClient> mockAutomationClient;
29+
30+
private MockCommandRuntime mockCommandRuntime;
31+
32+
private GetAzureAutomationWebhook cmdlet;
33+
34+
[TestInitialize]
35+
public void SetupTest()
36+
{
37+
this.mockAutomationClient = new Mock<IAutomationClient>();
38+
this.mockCommandRuntime = new MockCommandRuntime();
39+
this.cmdlet = new GetAzureAutomationWebhook
40+
{
41+
AutomationClient = this.mockAutomationClient.Object,
42+
CommandRuntime = this.mockCommandRuntime
43+
};
44+
}
45+
46+
[TestMethod]
47+
public void GetAzureAutomationWebhookByNameSuccessful()
48+
{
49+
// Setup
50+
string resourceGroupName = "resourceGroup";
51+
string accountName = "account";
52+
string webhookName = "webhookName";
53+
this.cmdlet.SetParameterSet("ByName");
54+
55+
this.mockAutomationClient.Setup(f => f.GetWebhook(resourceGroupName, accountName, webhookName));
56+
57+
// Test
58+
this.cmdlet.ResourceGroupName = resourceGroupName;
59+
this.cmdlet.AutomationAccountName = accountName;
60+
this.cmdlet.Name = webhookName;
61+
this.cmdlet.ExecuteCmdlet();
62+
63+
// Assert
64+
this.mockAutomationClient.Verify(f => f.GetWebhook(resourceGroupName, accountName, webhookName), Times.Once());
65+
}
66+
}
67+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.VisualStudio.TestTools.UnitTesting;
18+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Moq;
21+
using System;
22+
23+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
24+
{
25+
[TestClass]
26+
public class NewAzureAutomationWebhookTest : TestBase
27+
{
28+
private Mock<IAutomationClient> mockAutomationClient;
29+
30+
private MockCommandRuntime mockCommandRuntime;
31+
32+
private NewAzureAutomationWebhook cmdlet;
33+
34+
[TestInitialize]
35+
public void SetupTest()
36+
{
37+
this.mockAutomationClient = new Mock<IAutomationClient>();
38+
this.mockCommandRuntime = new MockCommandRuntime();
39+
this.cmdlet = new NewAzureAutomationWebhook
40+
{
41+
AutomationClient = this.mockAutomationClient.Object,
42+
CommandRuntime = this.mockCommandRuntime
43+
};
44+
}
45+
46+
[TestMethod]
47+
public void NewAzureAutomationWebhookByNameSuccessful()
48+
{
49+
// Setup
50+
string resourceGroupName = "resourceGroup";
51+
string accountName = "account";
52+
string name = "webhookName";
53+
string runbookName = "runbookName";
54+
DateTimeOffset expiryTime = DateTimeOffset.Now.AddDays(1);
55+
56+
this.mockAutomationClient.Setup(
57+
f => f.CreateWebhook(resourceGroupName, accountName, name, runbookName, true, expiryTime, null));
58+
59+
// Test
60+
this.cmdlet.ResourceGroupName = resourceGroupName;
61+
this.cmdlet.AutomationAccountName = accountName;
62+
this.cmdlet.Name = name;
63+
this.cmdlet.RunbookName = runbookName;
64+
this.cmdlet.ExpiryTime = expiryTime;
65+
this.cmdlet.IsEnabled = true;
66+
this.cmdlet.Parameters = null;
67+
this.cmdlet.ExecuteCmdlet();
68+
69+
// Assert
70+
this.mockAutomationClient.Verify(
71+
f => f.CreateWebhook(resourceGroupName, accountName, name, runbookName, true, expiryTime, null),
72+
Times.Once());
73+
}
74+
}
75+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.VisualStudio.TestTools.UnitTesting;
18+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
using Moq;
22+
23+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
24+
{
25+
[TestClass]
26+
public class RemoveAzureAutomationWebhookTest : TestBase
27+
{
28+
private Mock<IAutomationClient> mockAutomationClient;
29+
30+
private MockCommandRuntime mockCommandRuntime;
31+
32+
private RemoveAzureAutomationWebhook cmdlet;
33+
34+
[TestInitialize]
35+
public void SetupTest()
36+
{
37+
this.mockAutomationClient = new Mock<IAutomationClient>();
38+
this.mockCommandRuntime = new MockCommandRuntime();
39+
this.cmdlet = new RemoveAzureAutomationWebhook
40+
{
41+
AutomationClient = this.mockAutomationClient.Object,
42+
CommandRuntime = this.mockCommandRuntime
43+
};
44+
}
45+
46+
[TestMethod]
47+
public void RemoveAzureAutomationWebhookByNameSuccessful()
48+
{
49+
// Setup
50+
string resourceGroupName = "resourceGroup";
51+
string accountName = "account";
52+
string webhookName = "webhookName";
53+
this.cmdlet.SetParameterSet("ByName");
54+
55+
this.mockAutomationClient.Setup(f => f.DeleteWebhook(resourceGroupName, accountName, webhookName));
56+
57+
// Test
58+
this.cmdlet.ResourceGroupName = resourceGroupName;
59+
this.cmdlet.AutomationAccountName = accountName;
60+
this.cmdlet.Name = webhookName;
61+
this.cmdlet.ExecuteCmdlet();
62+
63+
// Assert
64+
this.mockAutomationClient.Verify(f => f.DeleteWebhook(resourceGroupName, accountName, webhookName), Times.Once());
65+
}
66+
}
67+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.VisualStudio.TestTools.UnitTesting;
18+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Moq;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
23+
{
24+
[TestClass]
25+
public class SetAzureAutomationWebhookTest : TestBase
26+
{
27+
private Mock<IAutomationClient> mockAutomationClient;
28+
29+
private MockCommandRuntime mockCommandRuntime;
30+
31+
private SetAzureAutomationWebhook cmdlet;
32+
33+
[TestInitialize]
34+
public void SetupTest()
35+
{
36+
this.mockAutomationClient = new Mock<IAutomationClient>();
37+
this.mockCommandRuntime = new MockCommandRuntime();
38+
this.cmdlet = new SetAzureAutomationWebhook
39+
{
40+
AutomationClient = this.mockAutomationClient.Object,
41+
CommandRuntime = this.mockCommandRuntime
42+
};
43+
}
44+
45+
[TestMethod]
46+
public void SetAzureAutomationWebhookToDisabledSuccessful()
47+
{
48+
// Setup
49+
string resourceGroupName = "resourceGroup";
50+
string accountName = "account";
51+
string name = "webhookName";
52+
53+
this.mockAutomationClient.Setup(
54+
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false));
55+
56+
// Test
57+
this.cmdlet.ResourceGroupName = resourceGroupName;
58+
this.cmdlet.AutomationAccountName = accountName;
59+
this.cmdlet.Name = name;
60+
this.cmdlet.IsEnabled = false;
61+
this.cmdlet.Parameters = null;
62+
this.cmdlet.ExecuteCmdlet();
63+
64+
// Assert
65+
this.mockAutomationClient.Verify(
66+
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false),
67+
Times.Once());
68+
}
69+
}
70+
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationAccount.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ public IAutomationClient AutomationClient
5252
/// <summary>
5353
/// Gets or sets the automation account name.
5454
/// </summary>
55-
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name.")]
56-
[ValidateNotNullOrEmpty]
55+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name.")]
56+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAutomationAccountName, Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name.")]
5757
public string ResourceGroupName { get; set; }
5858

5959
/// <summary>
6060
/// Gets or sets the automation account name.
6161
/// </summary>
62-
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAutomationAccountName, Position = 1, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
62+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAutomationAccountName, Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
6363
[Alias("AutomationAccountName")]
6464
[ValidateNotNullOrEmpty]
6565
public string Name { get; set; }
@@ -77,13 +77,19 @@ public override void ExecuteCmdlet()
7777
{
7878
this.AutomationClient.GetAutomationAccount(this.ResourceGroupName, this.Name)
7979
};
80+
this.WriteObject(ret, true);
8081
}
8182
else
8283
{
83-
ret = this.AutomationClient.ListAutomationAccounts(this.ResourceGroupName);
84-
}
84+
string nextLink = string.Empty;
8585

86-
this.WriteObject(ret, true);
86+
do
87+
{
88+
ret = this.AutomationClient.ListAutomationAccounts(this.ResourceGroupName, ref nextLink);
89+
this.WriteObject(ret, true);
90+
91+
} while (!string.IsNullOrEmpty(nextLink));
92+
}
8793
}
8894
}
8995
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationModule.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,19 @@ protected override void AutomationExecuteCmdlet()
4848
{
4949
this.AutomationClient.GetModule(this.ResourceGroupName, this.AutomationAccountName, this.Name)
5050
};
51+
this.GenerateCmdletOutput(ret);
5152
}
5253
else
5354
{
54-
ret = this.AutomationClient.ListModules(this.ResourceGroupName, this.AutomationAccountName);
55-
}
55+
string nextLink = string.Empty;
56+
57+
do
58+
{
59+
ret = this.AutomationClient.ListModules(this.ResourceGroupName, this.AutomationAccountName, ref nextLink);
60+
this.GenerateCmdletOutput(ret);
5661

57-
this.GenerateCmdletOutput(ret);
62+
} while (!string.IsNullOrEmpty(nextLink));
63+
}
5864
}
5965
}
6066
}

0 commit comments

Comments
 (0)