public GetAzureRmActionGroupTests(Xunit.Abstractions.ITestOutputHelper output) { TestExecutionHelpers.SetUpSessionAndProfile(); insightsOperationsMock = new Mock <IActionGroupsOperations>(); insightsManagementClientMock = new Mock <MonitorManagementClient>() { CallBase = true }; commandRuntimeMock = new Mock <ICommandRuntime>(); cmdlet = new GetAzureRmActionGroupCommand() { CommandRuntime = commandRuntimeMock.Object, MonitorManagementClient = insightsManagementClientMock.Object }; ActionGroupResource responseObject = ActionGroupsUtilities.CreateActionGroupResource(name: "actiongroup1", shortName: "ag1"); responseSimple = new AzureOperationResponse <ActionGroupResource>() { Body = responseObject }; responsePage = new AzureOperationResponse <IEnumerable <ActionGroupResource> >() { Body = new List <ActionGroupResource> { responseObject } }; insightsOperationsMock.Setup(f => f.GetWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <AzureOperationResponse <ActionGroupResource> >(responseSimple)) .Callback((string resourceGrp, string name, Dictionary <string, List <string> > headers, CancellationToken t) => { this.resourceGroup = resourceGrp; this.name = name; }); insightsOperationsMock.Setup(f => f.ListByResourceGroupWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <AzureOperationResponse <IEnumerable <ActionGroupResource> > >(responsePage)) .Callback((string resourceGrp, Dictionary <string, List <string> > headers, CancellationToken t) => { this.resourceGroup = resourceGrp; }); insightsOperationsMock.Setup(f => f.ListBySubscriptionIdWithHttpMessagesAsync(It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <AzureOperationResponse <IEnumerable <ActionGroupResource> > >(responsePage)) .Callback((Dictionary <string, List <string> > headers, CancellationToken t) => { }); insightsManagementClientMock.SetupGet(f => f.ActionGroups).Returns(this.insightsOperationsMock.Object); }
public AddAzureRmActionGroupTests(Xunit.Abstractions.ITestOutputHelper output) { TestExecutionHelpers.SetUpSessionAndProfile(); insightsOperationsMock = new Mock <IActionGroupsOperations>(); insightsManagementClientMock = new Mock <MonitorManagementClient>() { CallBase = true }; commandRuntimeMock = new Mock <ICommandRuntime>(); cmdlet = new SetAzureRmActionGroupCommand { CommandRuntime = commandRuntimeMock.Object, MonitorManagementClient = insightsManagementClientMock.Object }; response = new AzureOperationResponse <ActionGroupResource>() { Body = ActionGroupsUtilities.CreateActionGroupResource( name: "ActionGroupName", shortName: "AgShortName") }; insightsOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <ActionGroupResource>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(response)) .Callback((string resourceGrp, string name, ActionGroupResource createOrUpdateParams, Dictionary <string, List <string> > headers, CancellationToken t) => { this.resourceGroup = resourceGrp; this.name = name; this.createOrUpdatePrms = createOrUpdateParams; }); insightsManagementClientMock.SetupGet(f => f.ActionGroups).Returns(this.insightsOperationsMock.Object); // Setup Confirmation commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>())).Returns(true); commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>())).Returns(true); commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(true); commandRuntimeMock.Setup(f => f.ShouldContinue(It.IsAny <string>(), It.IsAny <string>())).Returns(true); }