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