コード例 #1
0
        public void GetCustomerFeed()
        {
            moq::Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new moq::Mock <CustomerFeedService.CustomerFeedServiceClient>(moq::MockBehavior.Strict);
            GetCustomerFeedRequest request = new GetCustomerFeedRequest
            {
                ResourceNameAsCustomerFeedName = gagvr::CustomerFeedName.FromCustomerCustomerFeed("[CUSTOMER]", "[CUSTOMER_FEED]"),
            };
            gagvr::CustomerFeed expectedResponse = new gagvr::CustomerFeed
            {
                ResourceNameAsCustomerFeedName = gagvr::CustomerFeedName.FromCustomerCustomerFeed("[CUSTOMER]", "[CUSTOMER_FEED]"),
                FeedAsFeedName   = gagvr::FeedName.FromCustomerFeed("[CUSTOMER]", "[FEED]"),
                PlaceholderTypes =
                {
                    gagve::PlaceholderTypeEnum.Types.PlaceholderType.Location,
                },
                MatchingFunction = new gagvc::MatchingFunction(),
                Status           = gagve::FeedLinkStatusEnum.Types.FeedLinkStatus.Enabled,
            };

            mockGrpcClient.Setup(x => x.GetCustomerFeed(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CustomerFeedServiceClient client   = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::CustomerFeed       response = client.GetCustomerFeed(request.ResourceName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public async stt::Task GetCustomerFeedRequestObjectAsync()
        {
            moq::Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new moq::Mock <CustomerFeedService.CustomerFeedServiceClient>(moq::MockBehavior.Strict);
            GetCustomerFeedRequest request = new GetCustomerFeedRequest
            {
                ResourceNameAsCustomerFeedName = gagvr::CustomerFeedName.FromCustomerCustomerFeed("[CUSTOMER]", "[CUSTOMER_FEED]"),
            };
            gagvr::CustomerFeed expectedResponse = new gagvr::CustomerFeed
            {
                ResourceNameAsCustomerFeedName = gagvr::CustomerFeedName.FromCustomerCustomerFeed("[CUSTOMER]", "[CUSTOMER_FEED]"),
                FeedAsFeedName   = gagvr::FeedName.FromCustomerFeed("[CUSTOMER]", "[FEED]"),
                PlaceholderTypes =
                {
                    gagve::PlaceholderTypeEnum.Types.PlaceholderType.Location,
                },
                MatchingFunction = new gagvc::MatchingFunction(),
                Status           = gagve::FeedLinkStatusEnum.Types.FeedLinkStatus.Enabled,
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gagvr::CustomerFeed responseCancellationToken = await client.GetCustomerFeedAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #3
0
        public async stt::Task MutateCustomerFeedsAsync()
        {
            moq::Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new moq::Mock <CustomerFeedService.CustomerFeedServiceClient>(moq::MockBehavior.Strict);
            MutateCustomerFeedsRequest request = new MutateCustomerFeedsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CustomerFeedOperation(),
                },
            };
            MutateCustomerFeedsResponse expectedResponse = new MutateCustomerFeedsResponse
            {
                Results =
                {
                    new MutateCustomerFeedResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCustomerFeedsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCustomerFeedsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CustomerFeedServiceClient   client = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerFeedsResponse responseCallSettings = await client.MutateCustomerFeedsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            MutateCustomerFeedsResponse responseCancellationToken = await client.MutateCustomerFeedsAsync(request.CustomerId, request.Operations, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #4
0
        public void MutateCustomerFeeds()
        {
            moq::Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new moq::Mock <CustomerFeedService.CustomerFeedServiceClient>(moq::MockBehavior.Strict);
            MutateCustomerFeedsRequest request = new MutateCustomerFeedsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CustomerFeedOperation(),
                },
            };
            MutateCustomerFeedsResponse expectedResponse = new MutateCustomerFeedsResponse
            {
                Results =
                {
                    new MutateCustomerFeedResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCustomerFeeds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CustomerFeedServiceClient   client   = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerFeedsResponse response = client.MutateCustomerFeeds(request.CustomerId, request.Operations);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #5
0
        public void MutateCustomerFeedsRequestObject()
        {
            moq::Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new moq::Mock <CustomerFeedService.CustomerFeedServiceClient>(moq::MockBehavior.Strict);
            MutateCustomerFeedsRequest request = new MutateCustomerFeedsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CustomerFeedOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = true,
                ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly,
            };
            MutateCustomerFeedsResponse expectedResponse = new MutateCustomerFeedsResponse
            {
                Results =
                {
                    new MutateCustomerFeedResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCustomerFeeds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CustomerFeedServiceClient   client   = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerFeedsResponse response = client.MutateCustomerFeeds(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #6
0
        public async Task MutateCustomerFeedsAsync3()
        {
            Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new Mock <CustomerFeedService.CustomerFeedServiceClient>(MockBehavior.Strict);
            MutateCustomerFeedsRequest request = new MutateCustomerFeedsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCustomerFeedsResponse expectedResponse = new MutateCustomerFeedsResponse();

            mockGrpcClient.Setup(x => x.MutateCustomerFeedsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCustomerFeedsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CustomerFeedServiceClient   client   = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerFeedsResponse response = await client.MutateCustomerFeedsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #7
0
        public void MutateCustomerFeeds3()
        {
            Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new Mock <CustomerFeedService.CustomerFeedServiceClient>(MockBehavior.Strict);
            MutateCustomerFeedsRequest request = new MutateCustomerFeedsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCustomerFeedsResponse expectedResponse = new MutateCustomerFeedsResponse();

            mockGrpcClient.Setup(x => x.MutateCustomerFeeds(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CustomerFeedServiceClient   client   = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerFeedsResponse response = client.MutateCustomerFeeds(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #8
0
        public void GetCustomerFeed2()
        {
            Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new Mock <CustomerFeedService.CustomerFeedServiceClient>(MockBehavior.Strict);
            GetCustomerFeedRequest request = new GetCustomerFeedRequest
            {
                ResourceName = new CustomerFeedName("[CUSTOMER]", "[CUSTOMER_FEED]").ToString(),
            };
            CustomerFeed expectedResponse = new CustomerFeed
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCustomerFeed(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CustomerFeedServiceClient client = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            CustomerFeed response            = client.GetCustomerFeed(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #9
0
        public async Task GetCustomerFeedAsync2()
        {
            Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new Mock <CustomerFeedService.CustomerFeedServiceClient>(MockBehavior.Strict);
            GetCustomerFeedRequest request = new GetCustomerFeedRequest
            {
                ResourceName = new CustomerFeedName("[CUSTOMER]", "[CUSTOMER_FEED]").ToString(),
            };
            CustomerFeed expectedResponse = new CustomerFeed
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCustomerFeedAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <CustomerFeed>(Task.FromResult(expectedResponse), null, null, null, null));
            CustomerFeedServiceClient client = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            CustomerFeed response            = await client.GetCustomerFeedAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #10
0
        public async Task MutateCustomerFeedsAsync()
        {
            Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new Mock <CustomerFeedService.CustomerFeedServiceClient>(MockBehavior.Strict);
            MutateCustomerFeedsRequest expectedRequest = new MutateCustomerFeedsRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateCustomerFeedsResponse expectedResponse = new MutateCustomerFeedsResponse();

            mockGrpcClient.Setup(x => x.MutateCustomerFeedsAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCustomerFeedsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CustomerFeedServiceClient client = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            IEnumerable <CustomerFeedOperation> operations = new List <CustomerFeedOperation>();
            bool partialFailure = true;
            bool validateOnly   = false;
            MutateCustomerFeedsResponse response = await client.MutateCustomerFeedsAsync(customerId, operations, partialFailure, validateOnly);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }