public async Task CreateLogMetricAsync()
        {
            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.CreateLogMetricAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <LogMetric>(Task.FromResult(expectedResponse), null, null, null, null));
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            ParentNameOneof        parent = ParentNameOneof.From(new ProjectName("[PROJECT]"));
            LogMetric metric   = new LogMetric();
            LogMetric response = await client.CreateLogMetricAsync(parent, metric);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public void CreateLogMetricResourceNames()
        {
            moq::Mock <MetricsServiceV2.MetricsServiceV2Client> mockGrpcClient = new moq::Mock <MetricsServiceV2.MetricsServiceV2Client>(moq::MockBehavior.Strict);
            CreateLogMetricRequest request = new CreateLogMetricRequest
            {
                ParentAsMetricName = 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.CreateLogMetric(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            MetricsServiceV2Client client = new MetricsServiceV2ClientImpl(mockGrpcClient.Object, null);
            LogMetric response            = client.CreateLogMetric(request.ParentAsMetricName, request.Metric);

            xunit::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
            {
                Name           = "name3373707",
                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();
        }
Ejemplo n.º 4
0
 /// <summary>Snippet for CreateLogMetric</summary>
 public void CreateLogMetric_RequestObject()
 {
     // Snippet: CreateLogMetric(CreateLogMetricRequest,CallSettings)
     // Create client
     MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.Create();
     // Initialize request argument(s)
     CreateLogMetricRequest request = new CreateLogMetricRequest
     {
         ParentAsParentNameOneof = ParentNameOneof.From(new ProjectName("[PROJECT]")),
         Metric = new LogMetric(),
     };
     // Make the request
     LogMetric response = metricsServiceV2Client.CreateLogMetric(request);
     // End snippet
 }
Ejemplo n.º 5
0
        /// <summary>Snippet for CreateLogMetricAsync</summary>
        public async Task CreateLogMetricAsync_RequestObject()
        {
            // Snippet: CreateLogMetricAsync(CreateLogMetricRequest,CallSettings)
            // Additional: CreateLogMetricAsync(CreateLogMetricRequest,CancellationToken)
            // Create client
            MetricsServiceV2Client metricsServiceV2Client = await MetricsServiceV2Client.CreateAsync();

            // Initialize request argument(s)
            CreateLogMetricRequest request = new CreateLogMetricRequest
            {
                ParentAsParentNameOneof = ParentNameOneof.From(new ProjectName("[PROJECT]")),
                Metric = new LogMetric(),
            };
            // Make the request
            LogMetric response = await metricsServiceV2Client.CreateLogMetricAsync(request);

            // End snippet
        }
Ejemplo n.º 6
0
        public async stt::Task CreateLogMetricResourceNamesAsync()
        {
            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.CreateLogMetricAsync(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.CreateLogMetricAsync(request.ParentAsProjectName, request.Metric, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

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