Exemplo n.º 1
0
        public async Task ShouldReturnSortedDescending()
        {
            // Arrange
            var getSortedProductQuery        = new GetSortedProductQuery("Descending");
            var getSortedProductQueryHandler = new GetSortedProductQueryHandler(
                StubProductsHttpClient.WithProducts(ListOfProduct.ANotSortedProductsFormLowToHigh),
                new RecommendationsService(StubShopperHistoryHttpClient.WithNoHistory()));

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

            // Assert
            getSortedProductQueryResponse.Products.Should().Equal(ListOfProduct.SortedDescending);
        }
Exemplo n.º 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();
        }