public AddAzureRmWebtestAlertRuleTests() { insightsAlertRuleOperationsMock = new Mock<IAlertOperations>(); insightsManagementClientMock = new Mock<InsightsManagementClient>(); commandRuntimeMock = new Mock<ICommandRuntime>(); cmdlet = new AddAzureRmWebtestAlertRuleCommand() { 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); }
public AddAzureRmWebtestAlertRuleTests(ITestOutputHelper output) { //XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output)); insightsAlertRuleOperationsMock = new Mock<IAlertRulesOperations>(); insightsManagementClientMock = new Mock<InsightsManagementClient>(); commandRuntimeMock = new Mock<ICommandRuntime>(); cmdlet = new AddAzureRmWebtestAlertRuleCommand() { CommandRuntime = commandRuntimeMock.Object, InsightsManagementClient = insightsManagementClientMock.Object }; AlertRuleResource alertRuleResourceInput = new AlertRuleResource(location: null, isEnabled: true, alertRuleResourceName: "a name"); 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 createOrUpdateParams, Dictionary<string, List<string>> headers, CancellationToken t) => { resourceGroup = resourceGrp; createOrUpdatePrms = createOrUpdateParams; }); insightsManagementClientMock.SetupGet(f => f.AlertRules).Returns(this.insightsAlertRuleOperationsMock.Object); }