예제 #1
0
        public void GetConsumerQuotaMetricRequestObject()
        {
            moq::Mock <ServiceUsage.ServiceUsageClient> mockGrpcClient = new moq::Mock <ServiceUsage.ServiceUsageClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetConsumerQuotaMetricRequest request = new GetConsumerQuotaMetricRequest
            {
                Name = "name1c9368b0",
                View = QuotaView.Basic,
            };
            ConsumerQuotaMetric expectedResponse = new ConsumerQuotaMetric
            {
                Name                = "name1c9368b0",
                DisplayName         = "display_name137f65c2",
                ConsumerQuotaLimits =
                {
                    new ConsumerQuotaLimit(),
                },
                Metric = "metric5283bc2c",
                Unit   = "unitebbd343e",
                DescendantConsumerQuotaLimits =
                {
                    new ConsumerQuotaLimit(),
                },
            };

            mockGrpcClient.Setup(x => x.GetConsumerQuotaMetric(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ServiceUsageClient  client   = new ServiceUsageClientImpl(mockGrpcClient.Object, null);
            ConsumerQuotaMetric response = client.GetConsumerQuotaMetric(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
 /// <summary>Snippet for GetConsumerQuotaMetric</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetConsumerQuotaMetricRequestObject()
 {
     // Create client
     ServiceUsageClient serviceUsageClient = ServiceUsageClient.Create();
     // Initialize request argument(s)
     GetConsumerQuotaMetricRequest request = new GetConsumerQuotaMetricRequest
     {
         Name = "",
         View = QuotaView.Unspecified,
     };
     // Make the request
     ConsumerQuotaMetric response = serviceUsageClient.GetConsumerQuotaMetric(request);
 }
        /// <summary>Snippet for GetConsumerQuotaMetricAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetConsumerQuotaMetricRequestObjectAsync()
        {
            // Create client
            ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();

            // Initialize request argument(s)
            GetConsumerQuotaMetricRequest request = new GetConsumerQuotaMetricRequest
            {
                Name = "",
                View = QuotaView.Unspecified,
            };
            // Make the request
            ConsumerQuotaMetric response = await serviceUsageClient.GetConsumerQuotaMetricAsync(request);
        }
예제 #4
0
        public async stt::Task GetConsumerQuotaMetricRequestObjectAsync()
        {
            moq::Mock <ServiceUsage.ServiceUsageClient> mockGrpcClient = new moq::Mock <ServiceUsage.ServiceUsageClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetConsumerQuotaMetricRequest request = new GetConsumerQuotaMetricRequest
            {
                Name = "name1c9368b0",
                View = QuotaView.Basic,
            };
            ConsumerQuotaMetric expectedResponse = new ConsumerQuotaMetric
            {
                Name                = "name1c9368b0",
                DisplayName         = "display_name137f65c2",
                ConsumerQuotaLimits =
                {
                    new ConsumerQuotaLimit(),
                },
                Metric = "metric5283bc2c",
                Unit   = "unitebbd343e",
                DescendantConsumerQuotaLimits =
                {
                    new ConsumerQuotaLimit(),
                },
            };

            mockGrpcClient.Setup(x => x.GetConsumerQuotaMetricAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ConsumerQuotaMetric>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ServiceUsageClient  client = new ServiceUsageClientImpl(mockGrpcClient.Object, null);
            ConsumerQuotaMetric responseCallSettings = await client.GetConsumerQuotaMetricAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ConsumerQuotaMetric responseCancellationToken = await client.GetConsumerQuotaMetricAsync(request, st::CancellationToken.None);

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