예제 #1
0
        public void ProductSearch()
        {
            var x = new StoreFrontRepository();

            var results = x.SearchProducts("cat");

            Assert.AreEqual(1, results.Count, "There is more than one cat");
        }
예제 #2
0
        public void AddToCart()
        {
            //Arrange
            var context = new StoreFrontRepository();
            var startingCart = context.GetACart();
            var startingCount = startingCart.Products.Count;

            //Act
            var product = context.SearchProducts("cat").First();
            context.AddItemToCart(product, startingCart);

            //Assert
            var endingCart = context.GetACart();
            Assert.Equals(startingCount + 1, endingCart.Products.Count);
        }
예제 #3
0
        public ActionResult Search(SearchViewModel model)
        {
            model.Name = HttpContext.User.Identity.Name;

            var repository = new StoreFrontRepository();

            var products = repository.SearchProducts(model.SearchText);

            model.Results = products.Select(x => new SearchResultViewModel
            {
                Id = x.Id,
                Name = x.Name,
                Price = x.Price,
                ImageFile = x.ImageFile
            }).ToList();

            return View("~/Views/ProductSearch/Index.cshtml", model);
        }