public async Task UpdateLogMetricAsync()
        {
            Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new Mock <MetricsServiceV2.MetricsServiceV2Client>(MockBehavior.Strict);
            UpdateLogMetricRequest expectedRequest = new UpdateLogMetricRequest
            {
                MetricNameAsMetricNameOneof = MetricNameOneof.From(new MetricName("[PROJECT]", "[METRIC]")),
                Metric = new LogMetric(),
            };
            LogMetric expectedResponse = new LogMetric
            {
                MetricNameOneof = MetricNameOneof.From(new MetricName("[PROJECT]", "[METRIC]")),
                Description     = "description-1724546052",
                Filter          = "filter-1274492040",
                ValueExtractor  = "valueExtractor2047672534",
            };

            mockGrpcClient.Setup(x => x.UpdateLogMetricAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <LogMetric>(Task.FromResult(expectedResponse), null, null, null, null));
            MetricsServiceV2Client client     = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            MetricNameOneof        metricName = MetricNameOneof.From(new MetricName("[PROJECT]", "[METRIC]"));
            LogMetric metric   = new LogMetric();
            LogMetric response = await client.UpdateLogMetricAsync(metricName, metric);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
        public async stt::Task UpdateLogMetricResourceNamesAsync()
        {
            moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict);
            UpdateLogMetricRequest request = new UpdateLogMetricRequest
            {
                MetricNameAsLogMetricName = LogMetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
                Metric = new LogMetric(),
            };
            LogMetric expectedResponse = new LogMetric
            {
                LogMetricName = LogMetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
                Description   = "description2cf9da67",
                Filter        = "filtere47ac9b2",
#pragma warning disable CS0612
                Version = LogMetric.Types.ApiVersion.V2,
#pragma warning restore CS0612
                MetricDescriptor = new ga::MetricDescriptor(),
                ValueExtractor   = "value_extractor09b994a6",
                LabelExtractors  =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                BucketOptions = new ga::Distribution.Types.BucketOptions(),
                CreateTime    = new wkt::Timestamp(),
                UpdateTime    = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.UpdateLogMetricAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <LogMetric>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            MetricsServiceV2Client client  = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            LogMetric responseCallSettings = await client.UpdateLogMetricAsync(request.MetricNameAsLogMetricName, request.Metric, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            LogMetric responseCancellationToken = await client.UpdateLogMetricAsync(request.MetricNameAsLogMetricName, request.Metric, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }