public void GetDetectionConfigurationsValidatesArguments() { MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient(); Assert.That(() => adminClient.GetDetectionConfigurationsAsync(null), Throws.InstanceOf <ArgumentNullException>()); Assert.That(() => adminClient.GetDetectionConfigurationsAsync(""), Throws.InstanceOf <ArgumentException>()); Assert.That(() => adminClient.GetDetectionConfigurationsAsync("metricId"), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException))); Assert.That(() => adminClient.GetDetectionConfigurations(null), Throws.InstanceOf <ArgumentNullException>()); Assert.That(() => adminClient.GetDetectionConfigurations(""), Throws.InstanceOf <ArgumentException>()); Assert.That(() => adminClient.GetDetectionConfigurations("metricId"), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException))); }
public void GetDetectionConfigurationsRespectsTheCancellationToken() { MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient(); using var cancellationSource = new CancellationTokenSource(); cancellationSource.Cancel(); IAsyncEnumerator <AnomalyDetectionConfiguration> asyncEnumerator = adminClient.GetDetectionConfigurationsAsync(FakeGuid, cancellationSource.Token).GetAsyncEnumerator(); Assert.That(async() => await asyncEnumerator.MoveNextAsync(), Throws.InstanceOf <OperationCanceledException>()); IEnumerator <AnomalyDetectionConfiguration> enumerator = adminClient.GetDetectionConfigurations(FakeGuid, cancellationSource.Token).GetEnumerator(); Assert.That(() => enumerator.MoveNext(), Throws.InstanceOf <OperationCanceledException>()); }