示例#1
0
        public async stt::Task GetHealthAsync()
        {
            moq::Mock <BackendServices.BackendServicesClient> mockGrpcClient = new moq::Mock <BackendServices.BackendServicesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetHealthBackendServiceRequest request = new GetHealthBackendServiceRequest
            {
                ResourceGroupReferenceResource = new ResourceGroupReference(),
                Project        = "projectaa6ff846",
                BackendService = "backend_serviceed490d45",
            };
            BackendServiceGroupHealth expectedResponse = new BackendServiceGroupHealth
            {
                Kind        = "kindf7aa39d9",
                Annotations =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                HealthStatus = { new HealthStatus(), },
            };

            mockGrpcClient.Setup(x => x.GetHealthAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <BackendServiceGroupHealth>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            BackendServicesClient     client = new BackendServicesClientImpl(mockGrpcClient.Object, null);
            BackendServiceGroupHealth responseCallSettings = await client.GetHealthAsync(request.Project, request.BackendService, request.ResourceGroupReferenceResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            BackendServiceGroupHealth responseCancellationToken = await client.GetHealthAsync(request.Project, request.BackendService, request.ResourceGroupReferenceResource, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
示例#2
0
        public void GetHealth()
        {
            moq::Mock <BackendServices.BackendServicesClient> mockGrpcClient = new moq::Mock <BackendServices.BackendServicesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetHealthBackendServiceRequest request = new GetHealthBackendServiceRequest
            {
                ResourceGroupReferenceResource = new ResourceGroupReference(),
                Project        = "projectaa6ff846",
                BackendService = "backend_serviceed490d45",
            };
            BackendServiceGroupHealth expectedResponse = new BackendServiceGroupHealth
            {
                Kind        = "kindf7aa39d9",
                Annotations =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                HealthStatus = { new HealthStatus(), },
            };

            mockGrpcClient.Setup(x => x.GetHealth(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            BackendServicesClient     client   = new BackendServicesClientImpl(mockGrpcClient.Object, null);
            BackendServiceGroupHealth response = client.GetHealth(request.Project, request.BackendService, request.ResourceGroupReferenceResource);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for GetHealth</summary>
 public void GetHealthRequestObject()
 {
     // Snippet: GetHealth(GetHealthBackendServiceRequest, CallSettings)
     // Create client
     BackendServicesClient backendServicesClient = BackendServicesClient.Create();
     // Initialize request argument(s)
     GetHealthBackendServiceRequest request = new GetHealthBackendServiceRequest
     {
         ResourceGroupReferenceResource = new ResourceGroupReference(),
         Project        = "",
         BackendService = "",
     };
     // Make the request
     BackendServiceGroupHealth response = backendServicesClient.GetHealth(request);
     // End snippet
 }
        /// <summary>Snippet for GetHealthAsync</summary>
        public async Task GetHealthRequestObjectAsync()
        {
            // Snippet: GetHealthAsync(GetHealthBackendServiceRequest, CallSettings)
            // Additional: GetHealthAsync(GetHealthBackendServiceRequest, CancellationToken)
            // Create client
            BackendServicesClient backendServicesClient = await BackendServicesClient.CreateAsync();

            // Initialize request argument(s)
            GetHealthBackendServiceRequest request = new GetHealthBackendServiceRequest
            {
                ResourceGroupReferenceResource = new ResourceGroupReference(),
                Project        = "",
                BackendService = "",
            };
            // Make the request
            BackendServiceGroupHealth response = await backendServicesClient.GetHealthAsync(request);

            // End snippet
        }