|
| 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