Пример #1
0
        public void GetAllFeedbackValidatesArguments()
        {
            MetricsAdvisorClient client = GetMetricsAdvisorClient();

            Assert.That(() => client.GetAllFeedbackAsync(null), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => client.GetAllFeedbackAsync(""), Throws.InstanceOf <ArgumentException>());

            Assert.That(() => client.GetAllFeedback(null), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => client.GetAllFeedback(""), Throws.InstanceOf <ArgumentException>());
        }
        public void GetAllFeedbackValidatesArguments()
        {
            MetricsAdvisorClient client = GetMetricsAdvisorClient();

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

            Assert.That(() => client.GetAllFeedback(null), Throws.InstanceOf <ArgumentNullException>());
            Assert.That(() => client.GetAllFeedback(""), Throws.InstanceOf <ArgumentException>());
            Assert.That(() => client.GetAllFeedback("metricId"), Throws.InstanceOf <ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
        }
        public void GetAllFeedbackRespectsTheCancellationToken()
        {
            MetricsAdvisorClient client = GetMetricsAdvisorClient();

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

            IAsyncEnumerator <MetricFeedback> asyncEnumerator = client.GetAllFeedbackAsync(FakeGuid, cancellationToken: cancellationSource.Token).GetAsyncEnumerator();

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

            IEnumerator <MetricFeedback> enumerator = client.GetAllFeedback(FakeGuid, cancellationToken: cancellationSource.Token).GetEnumerator();

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