Example #1
0
        public void UpdateAlertConfigurationValidatesArguments()
        {
            MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

            var config = new AnomalyAlertConfiguration();

            Assert.That(() => adminClient.UpdateAlertConfigurationAsync(null), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.UpdateAlertConfiguration(null), Throws.InstanceOf <ArgumentNullException>());

            var configurationWithNullId = new AnomalyAlertConfiguration();

            Assert.That(() => adminClient.UpdateAlertConfigurationAsync(configurationWithNullId), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.UpdateAlertConfiguration(configurationWithNullId), Throws.InstanceOf <ArgumentNullException>());
        }
        public void UpdateAlertConfigurationValidatesArguments()
        {
            MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

            var config = new AnomalyAlertConfiguration();

            Assert.That(() => adminClient.UpdateAlertConfigurationAsync(null, config), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.UpdateAlertConfigurationAsync("", config), Throws.InstanceOf <ArgumentException>());
            Assert.That(() => adminClient.UpdateAlertConfigurationAsync("configId", config), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
            Assert.That(() => adminClient.UpdateAlertConfigurationAsync(FakeGuid, null), Throws.InstanceOf <ArgumentNullException>());

            Assert.That(() => adminClient.UpdateAlertConfiguration(null, config), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.UpdateAlertConfiguration("", config), Throws.InstanceOf <ArgumentException>());
            Assert.That(() => adminClient.UpdateAlertConfiguration("configId", config), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
            Assert.That(() => adminClient.UpdateAlertConfiguration(FakeGuid, null), Throws.InstanceOf <ArgumentNullException>());
        }
        public void UpdateAlertConfigurationValidatesArguments()
        {
            MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

            var metricConfigs = new List <MetricAnomalyAlertConfiguration>()
            {
                new MetricAnomalyAlertConfiguration(FakeGuid, MetricAnomalyAlertScope.GetScopeForWholeSeries())
            };
            var config = new AnomalyAlertConfiguration("configName", new List <string>(), metricConfigs);

            Assert.That(() => adminClient.UpdateAlertConfigurationAsync(null, config), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.UpdateAlertConfigurationAsync("", config), Throws.InstanceOf <ArgumentException>());
            Assert.That(() => adminClient.UpdateAlertConfigurationAsync("configId", config), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
            Assert.That(() => adminClient.UpdateAlertConfigurationAsync(FakeGuid, null), Throws.InstanceOf <ArgumentNullException>());

            Assert.That(() => adminClient.UpdateAlertConfiguration(null, config), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.UpdateAlertConfiguration("", config), Throws.InstanceOf <ArgumentException>());
            Assert.That(() => adminClient.UpdateAlertConfiguration("configId", config), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
            Assert.That(() => adminClient.UpdateAlertConfiguration(FakeGuid, null), Throws.InstanceOf <ArgumentNullException>());
        }
        public void UpdateAlertConfigurationRespectsTheCancellationToken()
        {
            MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

            var config = new AnomalyAlertConfiguration();

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

            Assert.That(() => adminClient.UpdateAlertConfigurationAsync(FakeGuid, config, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>());
            Assert.That(() => adminClient.UpdateAlertConfiguration(FakeGuid, config, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>());
        }
        public void UpdateAlertConfigurationRespectsTheCancellationToken()
        {
            MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

            var metricConfigs = new List <MetricAnomalyAlertConfiguration>()
            {
                new MetricAnomalyAlertConfiguration(FakeGuid, MetricAnomalyAlertScope.GetScopeForWholeSeries())
            };
            var config = new AnomalyAlertConfiguration("configName", new List <string>(), metricConfigs);

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

            Assert.That(() => adminClient.UpdateAlertConfigurationAsync(FakeGuid, config, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>());
            Assert.That(() => adminClient.UpdateAlertConfiguration(FakeGuid, config, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>());
        }