Beispiel #1
0
            public void BadCustomerNoCart_ResultsNotNull()
            {
                // arrange
                string customerNumber            = "654321";
                string branchId                  = "FUT";
                IRecommendedItemsRepository repo = MakeRepo();

                // act
                List <RecommendedItemsModel> results = repo.GetRecommendedItemsForCustomer(customerNumber, branchId);

                // assert
                results.Should()
                .NotBeNull();
            }
        public ProductsReturn GetRecommendedItemsForCart(UserSelectedContext catalogInfo, List <string> cartItems, UserProfile profile, int?pageSize, bool?getImages)
        {
            List <RecommendedItemsModel> recommendedItems = _recommendedItemsRepository.GetRecommendedItemsForCustomer(catalogInfo.CustomerId, catalogInfo.BranchId, cartItems, 50);

            ProductsReturn productsReturn = _catalogRepository.GetProductsByIdsWithoutProprietaryItems(catalogInfo.BranchId, recommendedItems.Select(x => x.RecommendedItem).ToList());
            List <Product> validProducts  = new List <Product>();

            AddPricingInfo(productsReturn, catalogInfo);

            foreach (Product product in productsReturn.Products)
            {
                bool hasImages  = false;
                bool hasPricing = false;

                if (product.HasPrice)
                {
                    hasPricing = true;
                }

                if (product.HasPrice && getImages.HasValue == true && getImages.Value == true)
                {
                    _catalogLogic.AddProductImageInfo(product);

                    if (product.ProductImages.Any() == true)
                    {
                        hasImages = true;
                    }
                }

                if ((getImages.Equals(true) && hasImages == true) || (getImages.HasValue == false || getImages.Equals(false)))
                {
                    validProducts.Add(product);
                }

                if (pageSize.HasValue && validProducts.Count >= pageSize)
                {
                    break;
                }
            }

            productsReturn.Products = validProducts;

            GetAdditionalProductInfo(profile, productsReturn, catalogInfo, false);
            ApplyRecommendedTagging(productsReturn);

            return(productsReturn);
        }
Beispiel #3
0
            public void GoodCustomerCartWithMatchingItemNumber_ResultsNotNull()
            {
                // arrange
                List <string> cartItemsList = new List <string> {
                    "111111"
                };
                string customerNumber            = "123456";
                string branchId                  = "FUT";
                IRecommendedItemsRepository repo = MakeRepo();

                // act
                List <RecommendedItemsModel> results = repo.GetRecommendedItemsForCustomer(customerNumber, branchId, cartItemsList);

                // assert
                results.Should()
                .NotBeNull();
            }
Beispiel #4
0
            public void GoodCustomerCartWithMatchingItemNumberRequestingNoSetNumber_Resultsin4()
            {
                // arrange
                int           expected      = 4;
                List <string> cartItemsList = new List <string> {
                    "111111"
                };
                string customerNumber            = "123456";
                string branchId                  = "FUT";
                IRecommendedItemsRepository repo = MakeRepo();

                // act
                List <RecommendedItemsModel> results = repo.GetRecommendedItemsForCustomer(customerNumber, branchId, cartItemsList);

                // assert
                results.Count
                .Should()
                .Be(expected);
            }