public void GetLogMetricRequestObject() { moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict); GetLogMetricRequest request = new GetLogMetricRequest { MetricNameAsMetricName = MetricName.FromProjectMetric("[PROJECT]", "[METRIC]"), }; 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.GetLogMetric(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null); LogMetric response = client.GetLogMetric(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetLogMetric2() { Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new Mock <MetricsServiceV2.MetricsServiceV2Client>(MockBehavior.Strict); GetLogMetricRequest request = new GetLogMetricRequest { MetricNameAsMetricNameOneof = MetricNameOneof.From(new MetricName("[PROJECT]", "[METRIC]")), }; LogMetric expectedResponse = new LogMetric { MetricNameOneof = MetricNameOneof.From(new MetricName("[PROJECT]", "[METRIC]")), Description = "description-1724546052", Filter = "filter-1274492040", ValueExtractor = "valueExtractor2047672534", }; mockGrpcClient.Setup(x => x.GetLogMetric(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null); LogMetric response = client.GetLogMetric(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }