public async stt::Task MutateCampaignsAsync() { moq::Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new moq::Mock <CampaignService.CampaignServiceClient>(moq::MockBehavior.Strict); MutateCampaignsRequest request = new MutateCampaignsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignOperation(), }, }; MutateCampaignsResponse expectedResponse = new MutateCampaignsResponse { Results = { new MutateCampaignResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaignsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCampaignsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignsResponse responseCallSettings = await client.MutateCampaignsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateCampaignsResponse responseCancellationToken = await client.MutateCampaignsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task MutateCampaignsAsync3() { Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new Mock <CampaignService.CampaignServiceClient>(MockBehavior.Strict); MutateCampaignsRequest request = new MutateCampaignsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateCampaignsResponse expectedResponse = new MutateCampaignsResponse(); mockGrpcClient.Setup(x => x.MutateCampaignsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignsResponse response = await client.MutateCampaignsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task MutateCampaignsAsync() { Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new Mock <CampaignService.CampaignServiceClient>(MockBehavior.Strict); MutateCampaignsRequest expectedRequest = new MutateCampaignsRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateCampaignsResponse expectedResponse = new MutateCampaignsResponse(); mockGrpcClient.Setup(x => x.MutateCampaignsAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <CampaignOperation> operations = new List <CampaignOperation>(); bool partialFailure = true; bool validateOnly = false; MutateCampaignsResponse response = await client.MutateCampaignsAsync(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }