-
Notifications
You must be signed in to change notification settings - Fork 4k
Added Get-AzureRMAutomationHybridRunbookWorkerGroup cmdlet #2325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8771de5
New cmdlet Get-AzureRMAutomationHybridRunbookWorkerGroup
robplank 46f82b4
updates requested by Microsoft
robplank 8836dfd
updated help for get-AzureRMAutomationHybridRunbookWorkerGroup
robplank 610aedf
setting VS version back to 2013
robplank 43b3e98
removed lines added from a git action
robplank 94819e3
fixing merge conflicts
robplank 0739af6
fix formating
robplank fc349b2
fixed typo
robplank e540a57
add Unit Test
robplank 521df62
update Test
robplank f73250c
update unit test
robplank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
.../Automation/Commands.Automation.Test/UnitTests/GetAzureAutomationHybridWorkerGroupTest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Microsoft.Azure.Commands.Automation.Cmdlet; | ||
using Microsoft.Azure.Commands.Automation.Common; | ||
using Microsoft.Azure.Commands.Automation.Model; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using Moq; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests | ||
{ | ||
[TestClass] | ||
public class GetAzureAutomationHybridWorkerGroupTest : RMTestBase | ||
{ | ||
private Mock<IAutomationClient> mockAutomationClient; | ||
|
||
private MockCommandRuntime mockCommandRuntime; | ||
|
||
private GetAzureAutomationHybridWorkerGroup cmdlet; | ||
|
||
|
||
public GetAzureAutomationHybridWorkerGroupTest() | ||
{ | ||
this.mockAutomationClient = new Mock<IAutomationClient>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Xunit, this can just be in the class constructor, as long as it can run before each test. You can do suite-based intiailization using TestFixtures |
||
this.mockCommandRuntime = new MockCommandRuntime(); | ||
this.cmdlet = new GetAzureAutomationHybridWorkerGroup | ||
{ | ||
AutomationClient = this.mockAutomationClient.Object, | ||
CommandRuntime = this.mockCommandRuntime | ||
}; | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void GetAzureAutomationHybridWorkerGroupByNameSuccessfull() | ||
{ | ||
//Setup | ||
string resourceGroupName = "resourceGroup"; | ||
string accountName = "automation"; | ||
string hybridRunbookWorkerGroupName = "hybridRunbookWorkerGroup"; | ||
|
||
this.mockAutomationClient.Setup(f => f.GetHybridRunbookWorkerGroup(resourceGroupName, accountName, hybridRunbookWorkerGroupName)); | ||
|
||
// Test | ||
this.cmdlet.ResourceGroupName = resourceGroupName; | ||
this.cmdlet.AutomationAccountName = accountName; | ||
this.cmdlet.Name = hybridRunbookWorkerGroupName; | ||
this.cmdlet.SetParameterSet("ByName"); | ||
this.cmdlet.ExecuteCmdlet(); | ||
|
||
// Assert | ||
this.mockAutomationClient.Verify(f => f.GetHybridRunbookWorkerGroup(resourceGroupName, accountName, hybridRunbookWorkerGroupName), Times.Once()); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void GetAzureAutomationHybridWorkerGroupByAllSuccessfull() | ||
{ | ||
// Setup | ||
string resourceGroupName = "resourceGroup"; | ||
string accountName = "automation"; | ||
string nextLink = string.Empty; | ||
|
||
this.mockAutomationClient.Setup(f => f.ListHybridRunbookWorkerGroups(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<HybridRunbookWorkerGroup>()); ; | ||
|
||
// Test | ||
this.cmdlet.ResourceGroupName = resourceGroupName; | ||
this.cmdlet.AutomationAccountName = accountName; | ||
this.cmdlet.SetParameterSet("ByAll"); | ||
this.cmdlet.ExecuteCmdlet(); | ||
|
||
//Assert | ||
this.mockAutomationClient.Verify(f => f.ListHybridRunbookWorkerGroups(resourceGroupName, accountName, ref nextLink), Times.Once()); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationHybridWorkerGroup.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Management.Automation; | ||
using System.Security.Permissions; | ||
using Microsoft.Azure.Commands.Automation.Model; | ||
using Microsoft.Azure.Commands.Automation.Common; | ||
|
||
|
||
namespace Microsoft.Azure.Commands.Automation.Cmdlet | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "AzureRMAutomationHybridWorkerGroup", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)] | ||
[OutputType(typeof(HybridRunbookWorkerGroup))] | ||
public class GetAzureAutomationHybridWorkerGroup : AzureAutomationBaseCmdlet | ||
{ | ||
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName,Position = 2, Mandatory = false, ValueFromPipeline = true, HelpMessage = "The Hybrid Runbook Worker Group name")] | ||
[Alias("Group")] | ||
public string Name { get; set; } | ||
|
||
protected override void AutomationProcessRecord() | ||
{ | ||
if (this.ParameterSetName == AutomationCmdletParameterSets.ByName) | ||
{ | ||
IEnumerable<HybridRunbookWorkerGroup> ret = null; | ||
ret = new List<HybridRunbookWorkerGroup> { | ||
|
||
this.AutomationClient.GetHybridRunbookWorkerGroup(this.ResourceGroupName, this.AutomationAccountName, this.Name) | ||
}; | ||
this.GenerateCmdletOutput(ret); | ||
} | ||
else if(this.ParameterSetName == AutomationCmdletParameterSets.ByAll) | ||
{ | ||
var nextLink = string.Empty; | ||
do | ||
{ | ||
var results = this.AutomationClient.ListHybridRunbookWorkerGroups(this.ResourceGroupName, this.AutomationAccountName, ref nextLink); | ||
this.GenerateCmdletOutput(results); | ||
}while (!string.IsNullOrEmpty(nextLink)); | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robplank We no longer accept MSTest tests - please convert this to xunit, and you will be good. Mainly this is just re-attributing the methods, as the model for tests is largely the same