Beispiel #1
0
        public void ApplyRecommendation()
        {
            moq::Mock <RecommendationService.RecommendationServiceClient> mockGrpcClient = new moq::Mock <RecommendationService.RecommendationServiceClient>(moq::MockBehavior.Strict);
            ApplyRecommendationRequest request = new ApplyRecommendationRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new ApplyRecommendationOperation(),
                },
            };
            ApplyRecommendationResponse expectedResponse = new ApplyRecommendationResponse
            {
                Results =
                {
                    new ApplyRecommendationResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.ApplyRecommendation(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RecommendationServiceClient client   = new RecommendationServiceClientImpl(mockGrpcClient.Object, null);
            ApplyRecommendationResponse response = client.ApplyRecommendation(request.CustomerId, request.Operations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public void ApplyRecommendation3()
        {
            Mock <RecommendationService.RecommendationServiceClient> mockGrpcClient = new Mock <RecommendationService.RecommendationServiceClient>(MockBehavior.Strict);
            ApplyRecommendationRequest request = new ApplyRecommendationRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            ApplyRecommendationResponse expectedResponse = new ApplyRecommendationResponse();

            mockGrpcClient.Setup(x => x.ApplyRecommendation(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            RecommendationServiceClient client   = new RecommendationServiceClientImpl(mockGrpcClient.Object, null);
            ApplyRecommendationResponse response = client.ApplyRecommendation(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void ApplyRecommendation()
        {
            Mock <RecommendationService.RecommendationServiceClient> mockGrpcClient = new Mock <RecommendationService.RecommendationServiceClient>(MockBehavior.Strict);
            ApplyRecommendationRequest expectedRequest = new ApplyRecommendationRequest
            {
                CustomerId     = "customerId-1772061412",
                PartialFailure = true,
                Operations     = { },
            };
            ApplyRecommendationResponse expectedResponse = new ApplyRecommendationResponse();

            mockGrpcClient.Setup(x => x.ApplyRecommendation(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            RecommendationServiceClient client = new RecommendationServiceClientImpl(mockGrpcClient.Object, null);
            string customerId     = "customerId-1772061412";
            bool   partialFailure = true;
            IEnumerable <ApplyRecommendationOperation> operations = new List <ApplyRecommendationOperation>();
            ApplyRecommendationResponse response = client.ApplyRecommendation(customerId, partialFailure, operations);

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