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

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

            Assert.That(() => adminClient.GetHook(null), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => adminClient.GetHook(""), Throws.InstanceOf <ArgumentException>());
            Assert.That(() => adminClient.GetHook("hookId"), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
        }
Example #2
0
        public void GetHookRespectsTheCancellationToken()
        {
            MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient();

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

            Assert.That(() => adminClient.GetHookAsync(FakeGuid, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>());
            Assert.That(() => adminClient.GetHook(FakeGuid, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>());
        }