コード例 #1
0
            public async Task ShouldThrowIfCanceled(
                IMetric <double> metric,
                [Frozen, Substitute] IAmazonCloudWatch cloudwatch,
                [Target] CloudWatchMetricReporter reporter
                )
            {
                var         cancellationToken = new CancellationToken(true);
                Func <Task> func = () => reporter.Report(metric, cancellationToken);

                await func.Should().ThrowAsync <OperationCanceledException>();

                await cloudwatch.DidNotReceive().PutMetricDataAsync(Any <PutMetricDataRequest>(), Any <CancellationToken>());
            }
コード例 #2
0
            public async Task ShouldReportMetricDataToCloudWatchWithValue(
                IMetric <double> metric,
                [Frozen, Substitute] IAmazonCloudWatch cloudwatch,
                [Target] CloudWatchMetricReporter reporter
                )
            {
                var cancellationToken = new CancellationToken(false);

                await reporter.Report(metric, cancellationToken);

                await cloudwatch.Received().PutMetricDataAsync(Any <PutMetricDataRequest>(), Any <CancellationToken>());

                var request = (PutMetricDataRequest)cloudwatch.ReceivedCalls().ElementAt(0).GetArguments()[0];

                request.MetricData.Should().Contain(data =>
                                                    data.Value == metric.Value
                                                    );
            }
コード例 #3
0
            public async Task ShouldReportMetricDataToCloudWatchWithNamespace(
                string metricNamespace,
                IMetric <double> metric,
                [Frozen, Options] IOptions <MetricOptions> options,
                [Frozen, Substitute] IAmazonCloudWatch cloudwatch,
                [Target] CloudWatchMetricReporter reporter
                )
            {
                var cancellationToken = new CancellationToken(false);

                options.Value.Namespace = metricNamespace;

                await reporter.Report(metric, cancellationToken);

                await cloudwatch.Received().PutMetricDataAsync(Any <PutMetricDataRequest>(), Any <CancellationToken>());

                var request = (PutMetricDataRequest)cloudwatch.ReceivedCalls().ElementAt(0).GetArguments()[0];

                request.Namespace.Should().Be(metricNamespace);
            }