コード例 #1
0
        public DisableAzureRmActivityLogAlertTests(Xunit.Abstractions.ITestOutputHelper output)
        {
            ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
            TestExecutionHelpers.SetUpSessionAndProfile();
            insightsOperationsMock = new Mock <IActivityLogAlertsOperations>();
            monitorClientMock      = new Mock <MonitorManagementClient>();
            commandRuntimeMock     = new Mock <ICommandRuntime>();
            cmdlet = new DisableAzureRmActivityLogAlertCommand()
            {
                CommandRuntime          = commandRuntimeMock.Object,
                MonitorManagementClient = monitorClientMock.Object
            };

            response = new AzureOperationResponse <ActivityLogAlertResource>()
            {
                Body = ActivityLogAlertsUtilities.CreateActivityLogAlertResource(location: "westus", name: "alert1")
            };

            insightsOperationsMock.Setup(f => f.UpdateWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <ActivityLogAlertPatchBody>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <AzureOperationResponse <ActivityLogAlertResource> >(response))
            .Callback((string r, string n, ActivityLogAlertPatchBody b, Dictionary <string, List <string> > headers, CancellationToken t) =>
            {
                this.resourceGroup = r;
                this.name          = n;
                this.body          = b;
            });

            monitorClientMock.SetupGet(f => f.ActivityLogAlerts).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);
        }
コード例 #2
0
        public GetAzureRmActivityLogAlertTests(Xunit.Abstractions.ITestOutputHelper output)
        {
            ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
            TestExecutionHelpers.SetUpSessionAndProfile();
            insightsOperationsMock       = new Mock <IActivityLogAlertsOperations>();
            insightsManagementClientMock = new Mock <MonitorManagementClient>()
            {
                CallBase = true
            };
            commandRuntimeMock = new Mock <ICommandRuntime>();
            cmdlet             = new GetAzureRmActivityLogAlertCommand()
            {
                CommandRuntime          = commandRuntimeMock.Object,
                MonitorManagementClient = insightsManagementClientMock.Object
            };

            ActivityLogAlertResource responseObject = ActivityLogAlertsUtilities.CreateActivityLogAlertResource(location: "westus", name: "alert1");

            responseSimple = new AzureOperationResponse <ActivityLogAlertResource>()
            {
                Body = responseObject
            };

            responsePage = new AzureOperationResponse <IEnumerable <ActivityLogAlertResource> >()
            {
                Body = new List <ActivityLogAlertResource> {
                    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 <ActivityLogAlertResource> >(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 <ActivityLogAlertResource> > >(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 <ActivityLogAlertResource> > >(responsePage))
            .Callback((Dictionary <string, List <string> > headers, CancellationToken t) =>
                      {});

            insightsManagementClientMock.SetupGet(f => f.ActivityLogAlerts).Returns(this.insightsOperationsMock.Object);
        }