Example #1
0
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <TargetHttpsProxies.TargetHttpsProxiesClient> mockGrpcClient = new moq::Mock <TargetHttpsProxies.TargetHttpsProxiesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTargetHttpsProxyRequest request = new GetTargetHttpsProxyRequest
            {
                TargetHttpsProxy = "target_https_proxycf436352",
                Project          = "projectaa6ff846",
            };
            TargetHttpsProxy expectedResponse = new TargetHttpsProxy
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp   = "creation_timestamp235e59a1",
                AuthorizationPolicy = "authorization_policyb4cd090a",
                Region          = "regionedb20d96",
                Fingerprint     = "fingerprint009e6052",
                ProxyBind       = false,
                SslPolicy       = "ssl_policybf005a65",
                ServerTlsPolicy = "server_tls_policyc2b4dc10",
                SslCertificates =
                {
                    "ssl_certificates50ceaff5",
                },
                UrlMap       = "url_map3ccdbf57",
                Description  = "description2cf9da67",
                SelfLink     = "self_link7e87f12d",
                QuicOverride = "quic_override6404d0e0",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
        public void Get()
        {
            moq::Mock <TargetHttpsProxies.TargetHttpsProxiesClient> mockGrpcClient = new moq::Mock <TargetHttpsProxies.TargetHttpsProxiesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTargetHttpsProxyRequest request = new GetTargetHttpsProxyRequest
            {
                TargetHttpsProxy = "target_https_proxycf436352",
                Project          = "projectaa6ff846",
            };
            TargetHttpsProxy expectedResponse = new TargetHttpsProxy
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp   = "creation_timestamp235e59a1",
                AuthorizationPolicy = "authorization_policyb4cd090a",
                Region          = "regionedb20d96",
                Fingerprint     = "fingerprint009e6052",
                ProxyBind       = false,
                SslPolicy       = "ssl_policybf005a65",
                ServerTlsPolicy = "server_tls_policyc2b4dc10",
                SslCertificates =
                {
                    "ssl_certificates50ceaff5",
                },
                UrlMap       = "url_map3ccdbf57",
                Description  = "description2cf9da67",
                SelfLink     = "self_link7e87f12d",
                QuicOverride = TargetHttpsProxy.Types.QuicOverride.UndefinedQuicOverride,
            };

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

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