public void CreateDetectionConfigurationValidatesArguments() { MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient(); Assert.That(() => adminClient.CreateDetectionConfigurationAsync(null), Throws.InstanceOf <ArgumentNullException>()); Assert.That(() => adminClient.CreateDetectionConfiguration(null), Throws.InstanceOf <ArgumentNullException>()); }
public void CreateDetectionConfigurationRespectsTheCancellationToken() { MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient(); var config = new AnomalyDetectionConfiguration(FakeGuid, "configName", new ()); using var cancellationSource = new CancellationTokenSource(); cancellationSource.Cancel(); Assert.That(() => adminClient.CreateDetectionConfigurationAsync(config, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>()); Assert.That(() => adminClient.CreateDetectionConfiguration(config, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>()); }
public void CreateDetectionConfigurationValidatesArguments() { MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient(); var metricId = "metricId"; var name = "configName"; var conditions = new MetricWholeSeriesDetectionCondition(); var config = new AnomalyDetectionConfiguration() { MetricId = null, Name = name, WholeSeriesDetectionConditions = conditions }; Assert.That(() => adminClient.CreateDetectionConfigurationAsync(null), Throws.InstanceOf <ArgumentNullException>()); Assert.That(() => adminClient.CreateDetectionConfiguration(null), Throws.InstanceOf <ArgumentNullException>()); Assert.That(() => adminClient.CreateDetectionConfigurationAsync(config), Throws.InstanceOf <ArgumentNullException>()); Assert.That(() => adminClient.CreateDetectionConfiguration(config), Throws.InstanceOf <ArgumentNullException>()); config.MetricId = ""; Assert.That(() => adminClient.CreateDetectionConfigurationAsync(config), Throws.InstanceOf <ArgumentException>()); Assert.That(() => adminClient.CreateDetectionConfiguration(config), Throws.InstanceOf <ArgumentException>()); config.MetricId = metricId; config.Name = null; Assert.That(() => adminClient.CreateDetectionConfigurationAsync(config), Throws.InstanceOf <ArgumentNullException>()); Assert.That(() => adminClient.CreateDetectionConfiguration(config), Throws.InstanceOf <ArgumentNullException>()); config.Name = ""; Assert.That(() => adminClient.CreateDetectionConfigurationAsync(config), Throws.InstanceOf <ArgumentException>()); Assert.That(() => adminClient.CreateDetectionConfiguration(config), Throws.InstanceOf <ArgumentException>()); config.Name = name; config.WholeSeriesDetectionConditions = null; Assert.That(() => adminClient.CreateDetectionConfigurationAsync(config), Throws.InstanceOf <ArgumentNullException>()); Assert.That(() => adminClient.CreateDetectionConfiguration(config), Throws.InstanceOf <ArgumentNullException>()); }