Beispiel #1
0
        public async stt::Task DeleteLogMetricResourceNamesAsync()
        {
            moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict);
            DeleteLogMetricRequest request = new DeleteLogMetricRequest
            {
                MetricNameAsLogMetricName = LogMetricName.FromProjectMetric("[PROJECT]", "[METRIC]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

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

            await client.DeleteLogMetricAsync(request.MetricNameAsLogMetricName, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }
        public async Task DeleteLogMetricAsync2()
        {
            Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new Mock <MetricsServiceV2.MetricsServiceV2Client>(MockBehavior.Strict);
            DeleteLogMetricRequest request = new DeleteLogMetricRequest
            {
                MetricNameAsMetricNameOneof = MetricNameOneof.From(new MetricName("[PROJECT]", "[METRIC]")),
            };
            Empty expectedResponse = new Empty();

            mockGrpcClient.Setup(x => x.DeleteLogMetricAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null));
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            await client.DeleteLogMetricAsync(request);

            mockGrpcClient.VerifyAll();
        }