コード例 #1
0
        public async stt::Task GenerateProductMixIdeasAsync()
        {
            moq::Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new moq::Mock <ReachPlanService.ReachPlanServiceClient>(moq::MockBehavior.Strict);
            GenerateProductMixIdeasRequest request = new GenerateProductMixIdeasRequest
            {
                CustomerId          = "customer_id3b3724cb",
                PlannableLocationId = "plannable_location_idbae428fa",
                CurrencyCode        = "currency_code7f81e352",
                BudgetMicros        = 6302061979031921068L,
            };
            GenerateProductMixIdeasResponse expectedResponse = new GenerateProductMixIdeasResponse
            {
                ProductAllocation =
                {
                    new ProductAllocation(),
                },
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            GenerateProductMixIdeasResponse responseCancellationToken = await client.GenerateProductMixIdeasAsync(request.CustomerId, request.PlannableLocationId, request.CurrencyCode, request.BudgetMicros, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public async Task GenerateProductMixIdeasAsync()
        {
            Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new Mock <ReachPlanService.ReachPlanServiceClient>(MockBehavior.Strict);
            GenerateProductMixIdeasRequest request = new GenerateProductMixIdeasRequest
            {
                CustomerId          = "customerId-1772061412",
                PlannableLocationId = null,
                CurrencyCode        = null,
                BudgetMicros        = null,
                Preferences         = new Preferences(),
            };
            GenerateProductMixIdeasResponse expectedResponse = new GenerateProductMixIdeasResponse();

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

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