Ejemplo n.º 1
0
        public async stt::Task ValidateAsync()
        {
            moq::Mock <UrlMaps.UrlMapsClient> mockGrpcClient = new moq::Mock <UrlMaps.UrlMapsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            ValidateUrlMapRequest request = new ValidateUrlMapRequest
            {
                Project = "projectaa6ff846",
                UrlMap  = "url_map3ccdbf57",
                UrlMapsValidateRequestResource = new UrlMapsValidateRequest(),
            };
            UrlMapsValidateResponse expectedResponse = new UrlMapsValidateResponse
            {
                Result = new UrlMapValidationResult(),
            };

            mockGrpcClient.Setup(x => x.ValidateAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <UrlMapsValidateResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            UrlMapsClient           client = new UrlMapsClientImpl(mockGrpcClient.Object, null);
            UrlMapsValidateResponse responseCallSettings = await client.ValidateAsync(request.Project, request.UrlMap, request.UrlMapsValidateRequestResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            UrlMapsValidateResponse responseCancellationToken = await client.ValidateAsync(request.Project, request.UrlMap, request.UrlMapsValidateRequestResource, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for Validate</summary>
 public void ValidateRequestObject()
 {
     // Snippet: Validate(ValidateUrlMapRequest, CallSettings)
     // Create client
     UrlMapsClient urlMapsClient = UrlMapsClient.Create();
     // Initialize request argument(s)
     ValidateUrlMapRequest request = new ValidateUrlMapRequest
     {
         Project = "",
         UrlMap  = "",
         UrlMapsValidateRequestResource = new UrlMapsValidateRequest(),
     };
     // Make the request
     UrlMapsValidateResponse response = urlMapsClient.Validate(request);
     // End snippet
 }
        /// <summary>Snippet for ValidateAsync</summary>
        public async Task ValidateRequestObjectAsync()
        {
            // Snippet: ValidateAsync(ValidateUrlMapRequest, CallSettings)
            // Additional: ValidateAsync(ValidateUrlMapRequest, CancellationToken)
            // Create client
            UrlMapsClient urlMapsClient = await UrlMapsClient.CreateAsync();

            // Initialize request argument(s)
            ValidateUrlMapRequest request = new ValidateUrlMapRequest
            {
                Project = "",
                UrlMap  = "",
                UrlMapsValidateRequestResource = new UrlMapsValidateRequest(),
            };
            // Make the request
            UrlMapsValidateResponse response = await urlMapsClient.ValidateAsync(request);

            // End snippet
        }
Ejemplo n.º 4
0
        public void Validate()
        {
            moq::Mock <UrlMaps.UrlMapsClient> mockGrpcClient = new moq::Mock <UrlMaps.UrlMapsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            ValidateUrlMapRequest request = new ValidateUrlMapRequest
            {
                Project = "projectaa6ff846",
                UrlMap  = "url_map3ccdbf57",
                UrlMapsValidateRequestResource = new UrlMapsValidateRequest(),
            };
            UrlMapsValidateResponse expectedResponse = new UrlMapsValidateResponse
            {
                Result = new UrlMapValidationResult(),
            };

            mockGrpcClient.Setup(x => x.Validate(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            UrlMapsClient           client   = new UrlMapsClientImpl(mockGrpcClient.Object, null);
            UrlMapsValidateResponse response = client.Validate(request.Project, request.UrlMap, request.UrlMapsValidateRequestResource);

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