public void MutateCampaigns() { moq::Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new moq::Mock <CampaignService.CampaignServiceClient>(moq::MockBehavior.Strict); MutateCampaignsRequest request = new MutateCampaignsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignOperation(), }, }; MutateCampaignsResponse expectedResponse = new MutateCampaignsResponse { Results = { new MutateCampaignResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaigns(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignsResponse response = client.MutateCampaigns(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateCampaignsRequestObject() { moq::Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new moq::Mock <CampaignService.CampaignServiceClient>(moq::MockBehavior.Strict); MutateCampaignsRequest request = new MutateCampaignsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignOperation(), }, PartialFailure = false, ValidateOnly = true, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateCampaignsResponse expectedResponse = new MutateCampaignsResponse { Results = { new MutateCampaignResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaigns(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignsResponse response = client.MutateCampaigns(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateCampaigns3() { Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new Mock <CampaignService.CampaignServiceClient>(MockBehavior.Strict); MutateCampaignsRequest request = new MutateCampaignsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateCampaignsResponse expectedResponse = new MutateCampaignsResponse(); mockGrpcClient.Setup(x => x.MutateCampaigns(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignsResponse response = client.MutateCampaigns(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateCampaigns() { Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new Mock <CampaignService.CampaignServiceClient>(MockBehavior.Strict); MutateCampaignsRequest expectedRequest = new MutateCampaignsRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateCampaignsResponse expectedResponse = new MutateCampaignsResponse(); mockGrpcClient.Setup(x => x.MutateCampaigns(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <CampaignOperation> operations = new List <CampaignOperation>(); bool partialFailure = true; bool validateOnly = false; MutateCampaignsResponse response = client.MutateCampaigns(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }