public async stt::Task MutateKeywordPlansAsync() { moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict); MutateKeywordPlansRequest request = new MutateKeywordPlansRequest { CustomerId = "customer_id3b3724cb", Operations = { new KeywordPlanOperation(), }, }; MutateKeywordPlansResponse expectedResponse = new MutateKeywordPlansResponse { Results = { new MutateKeywordPlansResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateKeywordPlansAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateKeywordPlansResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlansResponse responseCallSettings = await client.MutateKeywordPlansAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); MutateKeywordPlansResponse responseCancellationToken = await client.MutateKeywordPlansAsync(request.CustomerId, request.Operations, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task MutateKeywordPlansAsync3() { Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict); MutateKeywordPlansRequest request = new MutateKeywordPlansRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateKeywordPlansResponse expectedResponse = new MutateKeywordPlansResponse(); mockGrpcClient.Setup(x => x.MutateKeywordPlansAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateKeywordPlansResponse>(Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlansResponse response = await client.MutateKeywordPlansAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task MutateKeywordPlansAsync() { Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict); MutateKeywordPlansRequest expectedRequest = new MutateKeywordPlansRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateKeywordPlansResponse expectedResponse = new MutateKeywordPlansResponse(); mockGrpcClient.Setup(x => x.MutateKeywordPlansAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateKeywordPlansResponse>(Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <KeywordPlanOperation> operations = new List <KeywordPlanOperation>(); bool partialFailure = true; bool validateOnly = false; MutateKeywordPlansResponse response = await client.MutateKeywordPlansAsync(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }