Exemple #1
0
        public async Task ShouldReturnSortedRecommended()
        {
            // Arrange
            var getSortedProductQuery        = new GetSortedProductQuery("Recommended");
            var getSortedProductQueryHandler = new GetSortedProductQueryHandler(
                StubProductsHttpClient.WithProducts(ListOfProduct.ANotSortedProductsFormLowToHigh),
                new RecommendationsService(StubShopperHistoryHttpClient.WithHistory(ShopperHistoryData.History)));

            // Act
            var getSortedProductQueryResponse = await getSortedProductQueryHandler.Handle(getSortedProductQuery);

            // Assert
            getSortedProductQueryResponse.Products.Should().Equal(ListOfProduct.SortedBasedOnRecommended);
        }
Exemple #2
0
        public async Task ShouldReturnEmptyListOfProducts()
        {
            // Arrange
            var getSortedProductQuery        = new GetSortedProductQuery("Low");
            var getSortedProductQueryHandler = new GetSortedProductQueryHandler(
                StubProductsHttpClient.WithEmptyProducts(),
                new RecommendationsService(StubShopperHistoryHttpClient.WithNoHistory()));

            // Act
            var getSortedProductQueryResponse = await getSortedProductQueryHandler.Handle(getSortedProductQuery);

            // Assert
            getSortedProductQueryResponse.Products.Should().BeEmpty();
        }
        public async Task SortUserReturnsCorrectDetails()
        {
            // Act
            var result = await new ProductController(
                new GetSortedProductQueryHandler(StubProductsHttpClient.WithEmptyProducts(),
                                                 new RecommendationsService(StubShopperHistoryHttpClient.WithNoHistory())))
                         .Sort("Low");

            // Assert
            var actionResult   = Assert.IsType <ActionResult <IEnumerable <Product> > >(result);
            var okObjectResult = Assert.IsType <OkObjectResult>(actionResult.Result);

            okObjectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var products = Assert.IsAssignableFrom <IEnumerable <Product> >(okObjectResult.Value);

            products.Should().BeEmpty();
        }