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();
        }
        public void CreateLogMetric()
        {
            Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new Mock <MetricsServiceV2.MetricsServiceV2Client>(MockBehavior.Strict);
            CreateLogMetricRequest expectedRequest = new CreateLogMetricRequest
            {
                ParentAsParentNameOneof = ParentNameOneof.From(new ProjectName("[PROJECT]")),
                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.CreateLogMetric(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            ParentNameOneof        parent = ParentNameOneof.From(new ProjectName("[PROJECT]"));
            LogMetric metric   = new LogMetric();
            LogMetric response = client.CreateLogMetric(parent, metric);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #3
0
        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();
        }
예제 #4
0
        public void DeleteLogMetricResourceNames()
        {
            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.DeleteLogMetric(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);

            client.DeleteLogMetric(request.MetricNameAsLogMetricName);
            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();
        }
        public void DeleteLogMetric2()
        {
            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.DeleteLogMetric(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);

            client.DeleteLogMetric(request);
            mockGrpcClient.VerifyAll();
        }
예제 #7
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();
        }
예제 #8
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();
        }
        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
            {
                Name           = "name3373707",
                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();
        }
예제 #10
0
        public void CreateLogMetricRequestObject()
        {
            moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict);
            CreateLogMetricRequest request = new CreateLogMetricRequest
            {
                ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                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.CreateLogMetric(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            LogMetric response            = client.CreateLogMetric(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task CreateLogMetricAsync2()
        {
            Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new Mock <MetricsServiceV2.MetricsServiceV2Client>(MockBehavior.Strict);
            CreateLogMetricRequest request = new CreateLogMetricRequest
            {
                ParentAsParentNameOneof = ParentNameOneof.From(new ProjectName("[PROJECT]")),
                Metric = new LogMetric(),
            };
            LogMetric expectedResponse = new LogMetric
            {
                Name           = "name3373707",
                Description    = "description-1724546052",
                Filter         = "filter-1274492040",
                ValueExtractor = "valueExtractor2047672534",
            };

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

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }