public void ProductValues_Are_Correctly_Mapped_And_Saved_For_EditProduct() { var product = new Product { Id = 101, AddedBy = "skp1", DateAdded = DateTime.Now.AddDays(-5), Description = "cool product", SmallImageUrl = "small.png", Title = "awesome product", UnitPrice = 33.99M, UnitsInStock = 10 }; var productList = new List<Product> { product }.AsQueryable(); MockRepository.Setup(x => x.Get<Product>()).Returns(productList); MockRepository.Setup(x => x.Save(product)); var storeAdminController = CreateController<StoreAdminController>(); var productView = new ProductView { Description = "cooler product", Title = "awesomer product", UnitPrice = 21.33M, DiscountPercentage = 10.11M, FullImageUrl = "fullerImg.jpg", Id = 101 }; ActionResult actionResult = storeAdminController.EditProduct(productView); MockRepository.VerifyAll(); Assert.That(actionResult,Is.TypeOf<RedirectToRouteResult>()); Assert.That(((RedirectToRouteResult)actionResult).RouteValues["action"],Is.EqualTo("ManageProducts")); }
public ShoppingCartItem(Product product) { _item = product; }
public void Every_Product_Belongs_To_A_Department() { var department = new Department { DateAdded = DateTime.Now.AddDays(-10), AddedBy = "StoreAdmin", Title = "Books", Importance = 1, Description = "The Book store", ImageUrl = "book.png" }; var product = new Product { DateAdded = DateTime.Now.AddDays(-2), AddedBy = "StoreAdmin", Title = "Ice Dream", Description = "All about Ice creams", SKU = "A1b2", UnitPrice = 24.34M, DiscountPercentage = 0.33M, UnitsInStock = 20, SmallImageUrl = "small.jpg", FullImageUrl = "big.png" }; using (var trx=_session.BeginTransaction()) { new PersistenceSpecification<Department>(_session, new PocoComparer()).VerifyTheMappings(department); product.Category = department; department.Products = new List<Product> {product}; _session.Save(department); var savedDept = _session.Get<Department>(department.Id); Assert.That(savedDept.Products.Count,Is.EqualTo(1)); Assert.That(savedDept.Products[0].AddedBy,Is.EqualTo("StoreAdmin")); Assert.That(savedDept.Products[0].SKU,Is.EqualTo("A1b2")); trx.Rollback(); } }