public void TestIndex() { var db = new HoangEntities(); var controller = new ProductControllerTest(); var result = controller.Index() as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(List <Product>)); Assert.AreEqual(db.Products.Count(), (result.Model as List <Product>).Count); }
public void TestEdit() { var controller = new ProductControllerTest(); var result0 = controller.Edit(0); Assert.IsInstanceOfType(result0, typeof(HttpNotFoundResult)); var db = new HoangEntities(); var item = db.Products.First(); var result1 = controller.Edit(item.id) as ViewResult; Assert.IsNotNull(result1); var model = result1.Model as Product; Assert.IsNotNull(model); Assert.AreEqual(item.id, model.id); }