Пример #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();
        }
        public async stt::Task SetUrlMapRequestObjectAsync()
        {
            moq::Mock <TargetHttpProxies.TargetHttpProxiesClient> mockGrpcClient = new moq::Mock <TargetHttpProxies.TargetHttpProxiesClient>(moq::MockBehavior.Strict);
            SetUrlMapTargetHttpProxyRequest request = new SetUrlMapTargetHttpProxyRequest
            {
                RequestId               = "request_id362c8df6",
                TargetHttpProxy         = "target_http_proxy02d2fd7b",
                Project                 = "projectaa6ff846",
                UrlMapReferenceResource = new UrlMapReference(),
            };
            Operation expectedResponse = new Operation
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                User = "******",
                Zone = "zone255f4ea8",
                CreationTimestamp   = "creation_timestamp235e59a1",
                StartTime           = "start_timebd8dd9c4",
                OperationGroupId    = "operation_group_idd2040cf0",
                TargetLink          = "target_link9b435dc0",
                Progress            = 278622268,
                Error               = new Error(),
                EndTime             = "end_time89285d30",
                Region              = "regionedb20d96",
                OperationType       = "operation_typeece9e153",
                Status              = Operation.Types.Status.Pending,
                HttpErrorMessage    = "http_error_messageb5ef3c7f",
                TargetId            = 6263187990225347157UL,
                ClientOperationId   = "client_operation_id4e51b631",
                StatusMessage       = "status_message2c618f86",
                HttpErrorStatusCode = 1766362655,
                Description         = "description2cf9da67",
                InsertTime          = "insert_time7467185a",
                SelfLink            = "self_link7e87f12d",
                Warnings            = { new Warnings(), },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void Patch()
        {
            moq::Mock <TargetHttpProxies.TargetHttpProxiesClient> mockGrpcClient = new moq::Mock <TargetHttpProxies.TargetHttpProxiesClient>(moq::MockBehavior.Strict);
            PatchTargetHttpProxyRequest request = new PatchTargetHttpProxyRequest
            {
                TargetHttpProxyResource = new TargetHttpProxy(),
                TargetHttpProxy         = "target_http_proxy02d2fd7b",
                Project = "projectaa6ff846",
            };
            Operation expectedResponse = new Operation
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                User = "******",
                Zone = "zone255f4ea8",
                CreationTimestamp   = "creation_timestamp235e59a1",
                StartTime           = "start_timebd8dd9c4",
                OperationGroupId    = "operation_group_idd2040cf0",
                TargetLink          = "target_link9b435dc0",
                Progress            = 278622268,
                Error               = new Error(),
                EndTime             = "end_time89285d30",
                Region              = "regionedb20d96",
                OperationType       = "operation_typeece9e153",
                Status              = Operation.Types.Status.Pending,
                HttpErrorMessage    = "http_error_messageb5ef3c7f",
                TargetId            = 6263187990225347157UL,
                ClientOperationId   = "client_operation_id4e51b631",
                StatusMessage       = "status_message2c618f86",
                HttpErrorStatusCode = 1766362655,
                Description         = "description2cf9da67",
                InsertTime          = "insert_time7467185a",
                SelfLink            = "self_link7e87f12d",
                Warnings            = { new Warnings(), },
            };

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

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