public void UpdateLogMetric() { 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.UpdateLogMetric(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null); MetricNameOneof metricName = MetricNameOneof.From(new MetricName("[PROJECT]", "[METRIC]")); LogMetric metric = new LogMetric(); LogMetric response = client.UpdateLogMetric(metricName, metric); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void UpdateLogMetricResourceNames() { moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict); UpdateLogMetricRequest request = new UpdateLogMetricRequest { MetricNameAsMetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"), Metric = new LogMetric(), }; LogMetric expectedResponse = new LogMetric { MetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"), Description = "description2cf9da67", Filter = "filtere47ac9b2", 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.UpdateLogMetric(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null); LogMetric response = client.UpdateLogMetric(request.MetricNameAsMetricName, request.Metric); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }