public void GetCustomer2() { Mock <CustomerService.CustomerServiceClient> mockGrpcClient = new Mock <CustomerService.CustomerServiceClient>(MockBehavior.Strict); GetCustomerRequest request = new GetCustomerRequest { ResourceName = new CustomerName("[CUSTOMER]").ToString(), }; Customer expectedResponse = new Customer { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetCustomer(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); CustomerServiceClient client = new CustomerServiceClientImpl(mockGrpcClient.Object, null); Customer response = client.GetCustomer(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetCustomerRequestObject() { moq::Mock <CustomerService.CustomerServiceClient> mockGrpcClient = new moq::Mock <CustomerService.CustomerServiceClient>(moq::MockBehavior.Strict); GetCustomerRequest request = new GetCustomerRequest { ResourceNameAsCustomerName = gagvr::CustomerName.FromCustomer("[CUSTOMER_ID]"), }; gagvr::Customer expectedResponse = new gagvr::Customer { ResourceNameAsCustomerName = gagvr::CustomerName.FromCustomer("[CUSTOMER_ID]"), CallReportingSetting = new gagvr::CallReportingSetting(), ConversionTrackingSetting = new gagvr::ConversionTrackingSetting(), RemarketingSetting = new gagvr::RemarketingSetting(), PayPerConversionEligibilityFailureReasons = { gagve::CustomerPayPerConversionEligibilityFailureReasonEnum.Types.CustomerPayPerConversionEligibilityFailureReason.HasCampaignWithSharedBudget, }, Id = -6774108720365892680L, DescriptiveName = "descriptive_nameee37a0bc", CurrencyCode = "currency_code7f81e352", TimeZone = "time_zone73f23b20", TrackingUrlTemplate = "tracking_url_template157f152a", FinalUrlSuffix = "final_url_suffix046ed37a", AutoTaggingEnabled = true, HasPartnersBadge = true, Manager = false, TestAccount = true, OptimizationScore = -4.7741588361660064E+17, OptimizationScoreWeight = -89016329767571470, }; mockGrpcClient.Setup(x => x.GetCustomer(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CustomerServiceClient client = new CustomerServiceClientImpl(mockGrpcClient.Object, null); gagvr::Customer response = client.GetCustomer(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }