public GetAlertRuleCommandTests() { insightsAlertRuleOperationsMock = new Mock<IAlertOperations>(); insightsManagementClientMock = new Mock<InsightsManagementClient>(); commandRuntimeMock = new Mock<ICommandRuntime>(); cmdlet = new GetAlertRuleCommand() { CommandRuntime = commandRuntimeMock.Object, InsightsManagementClient = insightsManagementClientMock.Object }; listResponse = Utilities.InitializeRuleListResponse(); singleResponse = Utilities.InitializeRuleGetResponse(); insightsAlertRuleOperationsMock.Setup(f => f.ListRulesAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult<RuleListResponse>(listResponse)) .Callback((string resourceGrp, string nameOrTargetUri, CancellationToken t) => { resourceGroup = resourceGrp; ruleNameOrTargetUri = nameOrTargetUri; }); insightsAlertRuleOperationsMock.Setup(f => f.GetRuleAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult<RuleGetResponse>(singleResponse)) .Callback((string resourceGrp, string nameOrTargetUri, CancellationToken t) => { resourceGroup = resourceGrp; ruleNameOrTargetUri = nameOrTargetUri; }); insightsManagementClientMock.SetupGet(f => f.AlertOperations).Returns(this.insightsAlertRuleOperationsMock.Object); }
/// <summary> /// Initializes a new instance of the PSAlertRule class. /// </summary> /// <param name="ruleSpec"></param> public PSAlertRuleNoDetails(RuleGetResponse ruleSpec) { this.Id = ruleSpec.Id; this.Location = ruleSpec.Location; this.Name = ruleSpec.Name; this.Properties = ruleSpec.Properties; this.Tags = ruleSpec.Tags; }
/// <summary> /// Initializes a new instance of the PSAlertRule class. /// </summary> /// <param name="ruleSpec"></param> public PSAlertRule(RuleGetResponse ruleSpec) { this.Id = ruleSpec.Id; this.Location = ruleSpec.Location; this.Name = ruleSpec.Name; this.Properties = new PSAlertRuleProperty(ruleSpec.Properties); this.Tags = new PSDictionaryElement(ruleSpec.Tags); }