コード例 #1
0
        public void GetAlertConfigurationsValidatesArguments()
        {
            MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

            Assert.That(() => adminClient.GetAlertConfigurationsAsync(null), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.GetAlertConfigurationsAsync(""), Throws.InstanceOf <ArgumentException>());
            Assert.That(() => adminClient.GetAlertConfigurationsAsync("metricId"), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));

            Assert.That(() => adminClient.GetAlertConfigurations(null), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.GetAlertConfigurations(""), Throws.InstanceOf <ArgumentException>());
            Assert.That(() => adminClient.GetAlertConfigurations("metricId"), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
        }
コード例 #2
0
        public void GetAlertConfigurationsRespectsTheCancellationToken()
        {
            MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

            using var cancellationSource = new CancellationTokenSource();
            cancellationSource.Cancel();

            IAsyncEnumerator <AnomalyAlertConfiguration> asyncEnumerator = adminClient.GetAlertConfigurationsAsync(FakeGuid, cancellationSource.Token).GetAsyncEnumerator();

            Assert.That(async() => await asyncEnumerator.MoveNextAsync(), Throws.InstanceOf <OperationCanceledException>());

            IEnumerator <AnomalyAlertConfiguration> enumerator = adminClient.GetAlertConfigurations(FakeGuid, cancellationSource.Token).GetEnumerator();

            Assert.That(() => enumerator.MoveNext(), Throws.InstanceOf <OperationCanceledException>());
        }