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