コード例 #1
0
        public async stt::Task MutateFeedMappingsAsync()
        {
            moq::Mock <FeedMappingService.FeedMappingServiceClient> mockGrpcClient = new moq::Mock <FeedMappingService.FeedMappingServiceClient>(moq::MockBehavior.Strict);
            MutateFeedMappingsRequest request = new MutateFeedMappingsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new FeedMappingOperation(),
                },
            };
            MutateFeedMappingsResponse expectedResponse = new MutateFeedMappingsResponse
            {
                Results =
                {
                    new MutateFeedMappingResult(),
                },
                PartialFailureError = new gr::Status(),
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            MutateFeedMappingsResponse responseCancellationToken = await client.MutateFeedMappingsAsync(request.CustomerId, request.Operations, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public async Task MutateFeedMappingsAsync3()
        {
            Mock <FeedMappingService.FeedMappingServiceClient> mockGrpcClient = new Mock <FeedMappingService.FeedMappingServiceClient>(MockBehavior.Strict);
            MutateFeedMappingsRequest request = new MutateFeedMappingsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateFeedMappingsResponse expectedResponse = new MutateFeedMappingsResponse();

            mockGrpcClient.Setup(x => x.MutateFeedMappingsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateFeedMappingsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            FeedMappingServiceClient   client   = new FeedMappingServiceClientImpl(mockGrpcClient.Object, null);
            MutateFeedMappingsResponse response = await client.MutateFeedMappingsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #3
0
        public async Task MutateFeedMappingsAsync()
        {
            Mock <FeedMappingService.FeedMappingServiceClient> mockGrpcClient = new Mock <FeedMappingService.FeedMappingServiceClient>(MockBehavior.Strict);
            MutateFeedMappingsRequest expectedRequest = new MutateFeedMappingsRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateFeedMappingsResponse expectedResponse = new MutateFeedMappingsResponse();

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

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