public async stt::Task MutateFeedItemTargetsAsync() { moq::Mock <FeedItemTargetService.FeedItemTargetServiceClient> mockGrpcClient = new moq::Mock <FeedItemTargetService.FeedItemTargetServiceClient>(moq::MockBehavior.Strict); MutateFeedItemTargetsRequest request = new MutateFeedItemTargetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new FeedItemTargetOperation(), }, }; MutateFeedItemTargetsResponse expectedResponse = new MutateFeedItemTargetsResponse { Results = { new MutateFeedItemTargetResult(), }, }; mockGrpcClient.Setup(x => x.MutateFeedItemTargetsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateFeedItemTargetsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FeedItemTargetServiceClient client = new FeedItemTargetServiceClientImpl(mockGrpcClient.Object, null); MutateFeedItemTargetsResponse responseCallSettings = await client.MutateFeedItemTargetsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateFeedItemTargetsResponse responseCancellationToken = await client.MutateFeedItemTargetsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateFeedItemTargetsRequestObjectAsync() { moq::Mock <FeedItemTargetService.FeedItemTargetServiceClient> mockGrpcClient = new moq::Mock <FeedItemTargetService.FeedItemTargetServiceClient>(moq::MockBehavior.Strict); MutateFeedItemTargetsRequest request = new MutateFeedItemTargetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new FeedItemTargetOperation(), }, ValidateOnly = true, PartialFailure = false, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateFeedItemTargetsResponse expectedResponse = new MutateFeedItemTargetsResponse { Results = { new MutateFeedItemTargetResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateFeedItemTargetsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateFeedItemTargetsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FeedItemTargetServiceClient client = new FeedItemTargetServiceClientImpl(mockGrpcClient.Object, null); MutateFeedItemTargetsResponse responseCallSettings = await client.MutateFeedItemTargetsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); MutateFeedItemTargetsResponse responseCancellationToken = await client.MutateFeedItemTargetsAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task MutateFeedItemTargetsAsync2() { Mock <FeedItemTargetService.FeedItemTargetServiceClient> mockGrpcClient = new Mock <FeedItemTargetService.FeedItemTargetServiceClient>(MockBehavior.Strict); MutateFeedItemTargetsRequest request = new MutateFeedItemTargetsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateFeedItemTargetsResponse expectedResponse = new MutateFeedItemTargetsResponse(); mockGrpcClient.Setup(x => x.MutateFeedItemTargetsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateFeedItemTargetsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); FeedItemTargetServiceClient client = new FeedItemTargetServiceClientImpl(mockGrpcClient.Object, null); MutateFeedItemTargetsResponse response = await client.MutateFeedItemTargetsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }