public async stt::Task MutateCustomerManagerLinkAsync() { moq::Mock <CustomerManagerLinkService.CustomerManagerLinkServiceClient> mockGrpcClient = new moq::Mock <CustomerManagerLinkService.CustomerManagerLinkServiceClient>(moq::MockBehavior.Strict); MutateCustomerManagerLinkRequest request = new MutateCustomerManagerLinkRequest { CustomerId = "customer_id3b3724cb", Operations = { new CustomerManagerLinkOperation(), }, }; MutateCustomerManagerLinkResponse expectedResponse = new MutateCustomerManagerLinkResponse { Results = { new MutateCustomerManagerLinkResult(), }, }; mockGrpcClient.Setup(x => x.MutateCustomerManagerLinkAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCustomerManagerLinkResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CustomerManagerLinkServiceClient client = new CustomerManagerLinkServiceClientImpl(mockGrpcClient.Object, null); MutateCustomerManagerLinkResponse responseCallSettings = await client.MutateCustomerManagerLinkAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateCustomerManagerLinkResponse responseCancellationToken = await client.MutateCustomerManagerLinkAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task MutateCustomerManagerLinkAsync2() { Mock <CustomerManagerLinkService.CustomerManagerLinkServiceClient> mockGrpcClient = new Mock <CustomerManagerLinkService.CustomerManagerLinkServiceClient>(MockBehavior.Strict); MutateCustomerManagerLinkRequest request = new MutateCustomerManagerLinkRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateCustomerManagerLinkResponse expectedResponse = new MutateCustomerManagerLinkResponse(); mockGrpcClient.Setup(x => x.MutateCustomerManagerLinkAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateCustomerManagerLinkResponse>(Task.FromResult(expectedResponse), null, null, null, null)); CustomerManagerLinkServiceClient client = new CustomerManagerLinkServiceClientImpl(mockGrpcClient.Object, null); MutateCustomerManagerLinkResponse response = await client.MutateCustomerManagerLinkAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }