public void ProductSearch() { var x = new StoreFrontRepository(); var results = x.SearchProducts("cat"); Assert.AreEqual(1, results.Count, "There is more than one cat"); }
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); }
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); }