public AddAzureRmMetricAlertRuleTests(ITestOutputHelper output) { ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output)); TestExecutionHelpers.SetUpSessionAndProfile(); insightsAlertRuleOperationsMock = new Mock <IAlertRulesOperations>(); insightsManagementClientMock = new Mock <MonitorManagementClient>(); commandRuntimeMock = new Mock <ICommandRuntime>(); cmdlet = new AddAzureRmMetricAlertRuleCommand() { CommandRuntime = commandRuntimeMock.Object, MonitorManagementClient = insightsManagementClientMock.Object }; AlertRuleResource alertRuleResourceInput = new AlertRuleResource() { AlertRuleResourceName = "a name", Location = null, IsEnabled = true }; response = new Rest.Azure.AzureOperationResponse <AlertRuleResource>() { Body = alertRuleResourceInput }; insightsAlertRuleOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <AlertRuleResource>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <Rest.Azure.AzureOperationResponse <AlertRuleResource> >(response)) .Callback((string resourceGrp, string name, AlertRuleResource alertRuleResourceIn, Dictionary <string, List <string> > headers, CancellationToken t) => { resourceGroup = resourceGrp; alertRuleResource = alertRuleResourceIn; }); insightsManagementClientMock.SetupGet(f => f.AlertRules).Returns(this.insightsAlertRuleOperationsMock.Object); }
public AddAzureRmMetricAlertRuleTests(ITestOutputHelper output) { XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output)); insightsAlertRuleOperationsMock = new Mock <IAlertOperations>(); insightsManagementClientMock = new Mock <InsightsManagementClient>(); commandRuntimeMock = new Mock <ICommandRuntime>(); cmdlet = new AddAzureRmMetricAlertRuleCommand() { CommandRuntime = commandRuntimeMock.Object, InsightsManagementClient = insightsManagementClientMock.Object }; response = new AzureOperationResponse() { RequestId = Guid.NewGuid().ToString(), StatusCode = HttpStatusCode.OK, }; insightsAlertRuleOperationsMock.Setup(f => f.CreateOrUpdateRuleAsync(It.IsAny <string>(), It.IsAny <RuleCreateOrUpdateParameters>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <AzureOperationResponse>(response)) .Callback((string resourceGrp, RuleCreateOrUpdateParameters createOrUpdateParams, CancellationToken t) => { resourceGroup = resourceGrp; createOrUpdatePrms = createOrUpdateParams; }); insightsManagementClientMock.SetupGet(f => f.AlertOperations).Returns(this.insightsAlertRuleOperationsMock.Object); }