예제 #1
0
        public void ListInvoices()
        {
            moq::Mock <InvoiceService.InvoiceServiceClient> mockGrpcClient = new moq::Mock <InvoiceService.InvoiceServiceClient>(moq::MockBehavior.Strict);
            ListInvoicesRequest request = new ListInvoicesRequest
            {
                CustomerId   = "customer_id3b3724cb",
                BillingSetup = "billing_setupa2c2701f",
                IssueYear    = "issue_yeara1ebdef1",
                IssueMonth   = gagve::MonthOfYearEnum.Types.MonthOfYear.January,
            };
            ListInvoicesResponse expectedResponse = new ListInvoicesResponse
            {
                Invoices =
                {
                    new gagvr::Invoice(),
                },
            };

            mockGrpcClient.Setup(x => x.ListInvoices(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            InvoiceServiceClient client   = new InvoiceServiceClientImpl(mockGrpcClient.Object, null);
            ListInvoicesResponse response = client.ListInvoices(request.CustomerId, request.BillingSetup, request.IssueYear, request.IssueMonth);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
        public async stt::Task ListInvoicesRequestObjectAsync()
        {
            moq::Mock <InvoiceService.InvoiceServiceClient> mockGrpcClient = new moq::Mock <InvoiceService.InvoiceServiceClient>(moq::MockBehavior.Strict);
            ListInvoicesRequest request = new ListInvoicesRequest
            {
                CustomerId   = "customer_id3b3724cb",
                BillingSetup = "billing_setupa2c2701f",
                IssueYear    = "issue_yeara1ebdef1",
                IssueMonth   = gagve::MonthOfYearEnum.Types.MonthOfYear.January,
            };
            ListInvoicesResponse expectedResponse = new ListInvoicesResponse
            {
                Invoices =
                {
                    new gagvr::Invoice(),
                },
            };

            mockGrpcClient.Setup(x => x.ListInvoicesAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ListInvoicesResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            InvoiceServiceClient client = new InvoiceServiceClientImpl(mockGrpcClient.Object, null);
            ListInvoicesResponse responseCallSettings = await client.ListInvoicesAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            Assert.AreEqual(expectedResponse, responseCallSettings);
            ListInvoicesResponse responseCancellationToken = await client.ListInvoicesAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task ListInvoicesAsync()
        {
            Mock <InvoiceService.InvoiceServiceClient> mockGrpcClient = new Mock <InvoiceService.InvoiceServiceClient>(MockBehavior.Strict);
            ListInvoicesRequest expectedRequest = new ListInvoicesRequest
            {
                CustomerId   = "customerId-1772061412",
                BillingSetup = "billingSetup-1181632583",
                IssueYear    = "issueYear1443510243",
                IssueMonth   = MonthOfYearEnum.Types.MonthOfYear.Unspecified,
            };
            ListInvoicesResponse expectedResponse = new ListInvoicesResponse();

            mockGrpcClient.Setup(x => x.ListInvoicesAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ListInvoicesResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            InvoiceServiceClient client = new InvoiceServiceClientImpl(mockGrpcClient.Object, null);
            string customerId           = "customerId-1772061412";
            string billingSetup         = "billingSetup-1181632583";
            string issueYear            = "issueYear1443510243";

            MonthOfYearEnum.Types.MonthOfYear issueMonth = MonthOfYearEnum.Types.MonthOfYear.Unspecified;
            ListInvoicesResponse response = await client.ListInvoicesAsync(customerId, billingSetup, issueYear, issueMonth);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void ListInvoices2()
        {
            Mock <InvoiceService.InvoiceServiceClient> mockGrpcClient = new Mock <InvoiceService.InvoiceServiceClient>(MockBehavior.Strict);
            ListInvoicesRequest request = new ListInvoicesRequest
            {
                CustomerId   = "customerId-1772061412",
                BillingSetup = "billingSetup-1181632583",
                IssueYear    = "issueYear1443510243",
                IssueMonth   = MonthOfYearEnum.Types.MonthOfYear.Unspecified,
            };
            ListInvoicesResponse expectedResponse = new ListInvoicesResponse();

            mockGrpcClient.Setup(x => x.ListInvoices(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            InvoiceServiceClient client   = new InvoiceServiceClientImpl(mockGrpcClient.Object, null);
            ListInvoicesResponse response = client.ListInvoices(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }