Skip to content

Commit e540a57

Browse files
committed
add Unit Test
1 parent fc349b2 commit e540a57

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@
102102
<SpecificVersion>False</SpecificVersion>
103103
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
104104
</Reference>
105-
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
105+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
106+
<Private>False</Private>
107+
</Reference>
106108
<Reference Include="Microsoft.WindowsAzure.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
107109
<SpecificVersion>False</SpecificVersion>
108110
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
@@ -189,6 +191,7 @@
189191
<Compile Include="UnitTests\StartAzureAutomationRunbookTest.cs" />
190192
<Compile Include="UnitTests\StopAzureAutomationJobTest.cs" />
191193
<Compile Include="UnitTests\SuspendAzureAutomationJobTest.cs" />
194+
<Compile Include="UnitTests\GetAzureAutomationHybridWorkerGroupTest.cs" />
192195
<Compile Include="UnitTests\UnregisterAzureAutomationScheduledRunbookTest.cs" />
193196
</ItemGroup>
194197
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using Microsoft.Azure.Commands.Automation.Cmdlet;
2+
using Microsoft.Azure.Commands.Automation.Common;
3+
using Microsoft.Azure.Commands.Automation.Model;
4+
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
6+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
7+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
8+
using Moq;
9+
using System.Collections.Generic;
10+
11+
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
12+
{
13+
[TestClass]
14+
public class GetAzureAutomationHybridWorkerGroupTest : RMTestBase
15+
{
16+
private Mock<IAutomationClient> mockAutomationClient;
17+
18+
private MockCommandRuntime mockCommandRuntime;
19+
20+
private GetAzureAutomationHybridWorkerGroup cmdlet;
21+
22+
[TestInitialize]
23+
public void SetupTest()
24+
{
25+
this.mockAutomationClient = new Mock<IAutomationClient>();
26+
this.mockCommandRuntime = new MockCommandRuntime();
27+
this.cmdlet = new GetAzureAutomationHybridWorkerGroup
28+
{
29+
AutomationClient = this.mockAutomationClient.Object,
30+
CommandRuntime = this.mockCommandRuntime
31+
};
32+
}
33+
34+
[TestMethod]
35+
public void GetAzureAutomationHybridWorkerGroupByNameSuccessfull()
36+
{
37+
//Setup
38+
string resourceGroupName = "resourceGroup";
39+
string accountName = "automation";
40+
string hybridRunbookWorkerGroupName = "hybridRunbookWorkerGroup";
41+
42+
this.mockAutomationClient.Setup(f => f.GetHybridRunbookWorkerGroup(resourceGroupName, accountName, hybridRunbookWorkerGroupName));
43+
44+
// Test
45+
this.cmdlet.ResourceGroupName = resourceGroupName;
46+
this.cmdlet.AutomationAccountName = accountName;
47+
this.cmdlet.Name = hybridRunbookWorkerGroupName;
48+
this.cmdlet.SetParameterSet("ByName");
49+
this.cmdlet.ExecuteCmdlet();
50+
51+
// Assert
52+
this.mockAutomationClient.Verify(f => f.GetHybridRunbookWorkerGroup(resourceGroupName, accountName, hybridRunbookWorkerGroupName), Times.Once());
53+
}
54+
55+
[TestMethod]
56+
public void GetAzureAutomationHybridWorkerGroupByAllSuccessfull()
57+
{
58+
// Setup
59+
string resourceGroupName = "resourceGroup";
60+
string accountName = "automation";
61+
string nextLink = string.Empty;
62+
63+
this.mockAutomationClient.Setup(f => f.ListHybridRunbookWorkerGroups(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<HybridRunbookWorkerGroup>()); ;
64+
65+
// Test
66+
this.cmdlet.ResourceGroupName = resourceGroupName;
67+
this.cmdlet.AutomationAccountName = accountName;
68+
this.cmdlet.SetParameterSet("ByAll");
69+
this.cmdlet.ExecuteCmdlet();
70+
71+
//Assert
72+
this.mockAutomationClient.Verify(f => f.ListHybridRunbookWorkerGroups(resourceGroupName, accountName, ref nextLink), Times.Once());
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)