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