/// <summary> /// Creating a new instance of <see cref="EmulationAlert"/> for unit tests. /// </summary> /// <param name="alert">The alert to wrap</param> /// <returns>An emulation alert</returns> public static EmulationAlert CreateEmulationAlert(Alert alert) { string resourceId = alert.ResourceIdentifier.ResourceType == ResourceType.ApplicationInsights ? appInsightsResourceId : virtualMachineResourceId; QueryRunInfo queryRunInfo = new QueryRunInfo { Type = alert.ResourceIdentifier.ResourceType == ResourceType.ApplicationInsights ? TelemetryDbType.ApplicationInsights : TelemetryDbType.LogAnalytics, ResourceIds = new List <string>() { resourceId } }; var request = new SmartDetectorExecutionRequest { ResourceIds = new List <string>() { resourceId }, SmartDetectorId = "smartDetectorId", Cadence = TimeSpan.FromDays(1), }; ContractsAlert contractsAlert = alert.CreateContractsAlert(request, "smartDetectorName", queryRunInfo, usedLogAnalysisClient: false, usedMetricClient: false); return(new EmulationAlert(contractsAlert, ExtendedDateTime.UtcNow)); }
private static ContractsAlert CreateContractsAlert(Alert alert, bool nullQueryRunInfo = false, bool usedLogAnalysisClient = false, bool usedMetricClient = false) { QueryRunInfo queryRunInfo = null; if (!nullQueryRunInfo) { queryRunInfo = new QueryRunInfo { Type = alert.ResourceIdentifier.ResourceType == ResourceType.ApplicationInsights ? TelemetryDbType.ApplicationInsights : TelemetryDbType.LogAnalytics, ResourceIds = new List <string>() { "resourceId1", "resourceId2" } }; } string resourceId = "resourceId"; var request = new SmartDetectorExecutionRequest { ResourceIds = new List <string>() { resourceId }, SmartDetectorId = "smartDetectorId", Cadence = TimeSpan.FromDays(1), }; return(alert.CreateContractsAlert(request, SmartDetectorName, queryRunInfo, usedLogAnalysisClient, usedMetricClient)); }
private ContractsAlert CreatePresentation(Alert alert, bool nullQueryRunInfo = false) { QueryRunInfo queryRunInfo = null; if (!nullQueryRunInfo) { queryRunInfo = new QueryRunInfo { Type = alert.ResourceIdentifier.ResourceType == ResourceType.ApplicationInsights ? TelemetryDbType.ApplicationInsights : TelemetryDbType.LogAnalytics, ResourceIds = new List <string>() { "resourceId1", "resourceId2" } }; } string resourceId = "resourceId"; var request = new SmartDetectorExecutionRequest { ResourceIds = new List <string>() { resourceId }, SmartDetectorId = "smartDetectorId", DataEndTime = DateTime.UtcNow.AddMinutes(-20), Cadence = TimeSpan.FromDays(1), }; return(alert.CreateContractsAlert(request, SmartDetectorName, queryRunInfo)); }