Exemplo n.º 1
0
        public void Get()
        {
            moq::Mock <TargetHttpProxies.TargetHttpProxiesClient> mockGrpcClient = new moq::Mock <TargetHttpProxies.TargetHttpProxiesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTargetHttpProxyRequest request = new GetTargetHttpProxyRequest
            {
                TargetHttpProxy = "target_http_proxy02d2fd7b",
                Project         = "projectaa6ff846",
            };
            TargetHttpProxy expectedResponse = new TargetHttpProxy
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                Region            = "regionedb20d96",
                Fingerprint       = "fingerprint009e6052",
                ProxyBind         = false,
                UrlMap            = "url_map3ccdbf57",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TargetHttpProxiesClient client   = new TargetHttpProxiesClientImpl(mockGrpcClient.Object, null);
            TargetHttpProxy         response = client.Get(request.Project, request.TargetHttpProxy);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetAsync()
        {
            moq::Mock <TargetHttpProxies.TargetHttpProxiesClient> mockGrpcClient = new moq::Mock <TargetHttpProxies.TargetHttpProxiesClient>(moq::MockBehavior.Strict);
            GetTargetHttpProxyRequest request = new GetTargetHttpProxyRequest
            {
                TargetHttpProxy = "target_http_proxy02d2fd7b",
                Project         = "projectaa6ff846",
            };
            TargetHttpProxy expectedResponse = new TargetHttpProxy
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                Region            = "regionedb20d96",
                Fingerprint       = "fingerprint009e6052",
                ProxyBind         = false,
                UrlMap            = "url_map3ccdbf57",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            TargetHttpProxy responseCancellationToken = await client.GetAsync(request.Project, request.TargetHttpProxy, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 3
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetTargetHttpProxyRequest, CallSettings)
     // Create client
     TargetHttpProxiesClient targetHttpProxiesClient = TargetHttpProxiesClient.Create();
     // Initialize request argument(s)
     GetTargetHttpProxyRequest request = new GetTargetHttpProxyRequest
     {
         TargetHttpProxy = "",
         Project         = "",
     };
     // Make the request
     TargetHttpProxy response = targetHttpProxiesClient.Get(request);
     // End snippet
 }
Exemplo n.º 4
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetTargetHttpProxyRequest, CallSettings)
            // Additional: GetAsync(GetTargetHttpProxyRequest, CancellationToken)
            // Create client
            TargetHttpProxiesClient targetHttpProxiesClient = await TargetHttpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            GetTargetHttpProxyRequest request = new GetTargetHttpProxyRequest
            {
                TargetHttpProxy = "",
                Project         = "",
            };
            // Make the request
            TargetHttpProxy response = await targetHttpProxiesClient.GetAsync(request);

            // End snippet
        }