public void MutateFeeds() { moq::Mock <FeedService.FeedServiceClient> mockGrpcClient = new moq::Mock <FeedService.FeedServiceClient>(moq::MockBehavior.Strict); MutateFeedsRequest request = new MutateFeedsRequest { CustomerId = "customer_id3b3724cb", Operations = { new FeedOperation(), }, }; MutateFeedsResponse expectedResponse = new MutateFeedsResponse { Results = { new MutateFeedResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateFeeds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); FeedServiceClient client = new FeedServiceClientImpl(mockGrpcClient.Object, null); MutateFeedsResponse response = client.MutateFeeds(request.CustomerId, request.Operations); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateFeedsRequestObject() { moq::Mock <FeedService.FeedServiceClient> mockGrpcClient = new moq::Mock <FeedService.FeedServiceClient>(moq::MockBehavior.Strict); MutateFeedsRequest request = new MutateFeedsRequest { CustomerId = "customer_id3b3724cb", Operations = { new FeedOperation(), }, PartialFailure = false, ValidateOnly = true, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateFeedsResponse expectedResponse = new MutateFeedsResponse { Results = { new MutateFeedResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateFeeds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); FeedServiceClient client = new FeedServiceClientImpl(mockGrpcClient.Object, null); MutateFeedsResponse response = client.MutateFeeds(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateFeeds2() { Mock <FeedService.FeedServiceClient> mockGrpcClient = new Mock <FeedService.FeedServiceClient>(MockBehavior.Strict); MutateFeedsRequest request = new MutateFeedsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateFeedsResponse expectedResponse = new MutateFeedsResponse(); mockGrpcClient.Setup(x => x.MutateFeeds(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); FeedServiceClient client = new FeedServiceClientImpl(mockGrpcClient.Object, null); MutateFeedsResponse response = client.MutateFeeds(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateFeeds() { Mock <FeedService.FeedServiceClient> mockGrpcClient = new Mock <FeedService.FeedServiceClient>(MockBehavior.Strict); MutateFeedsRequest expectedRequest = new MutateFeedsRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateFeedsResponse expectedResponse = new MutateFeedsResponse(); mockGrpcClient.Setup(x => x.MutateFeeds(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); FeedServiceClient client = new FeedServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <FeedOperation> operations = new List <FeedOperation>(); bool partialFailure = true; bool validateOnly = false; MutateFeedsResponse response = client.MutateFeeds(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }