コード例 #1
0
        public async stt::Task ListPlannableProductsAsync()
        {
            moq::Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new moq::Mock <ReachPlanService.ReachPlanServiceClient>(moq::MockBehavior.Strict);
            ListPlannableProductsRequest request = new ListPlannableProductsRequest
            {
                PlannableLocationId = "plannable_location_idbae428fa",
            };
            ListPlannableProductsResponse expectedResponse = new ListPlannableProductsResponse
            {
                ProductMetadata =
                {
                    new ProductMetadata(),
                },
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            ListPlannableProductsResponse responseCancellationToken = await client.ListPlannableProductsAsync(request.PlannableLocationId, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public async Task ListPlannableProductsAsync2()
        {
            Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new Mock <ReachPlanService.ReachPlanServiceClient>(MockBehavior.Strict);
            ListPlannableProductsRequest request = new ListPlannableProductsRequest
            {
                PlannableLocationId = null,
            };
            ListPlannableProductsResponse expectedResponse = new ListPlannableProductsResponse();

            mockGrpcClient.Setup(x => x.ListPlannableProductsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ListPlannableProductsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ReachPlanServiceClient        client   = new ReachPlanServiceClientImpl(mockGrpcClient.Object, null);
            ListPlannableProductsResponse response = await client.ListPlannableProductsAsync(request);

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