public void TestDetailsViewData() { int _id = 2; HomeController _controller = new HomeController(); Product _expected = new Product { Id = _id, Name = "Data" }; _controller.Details(_id).AssertViewRendered().WithViewData<Product>().ShouldEqual(_expected,"TestDetailsViewData"); }
public ViewResult Details(int Id) { Product _item = new Product{Id=Id, Name="Data"}; return View("Details",_item); }
public ActionResult Category(int Id) { if (Id < 0) { return RedirectToAction("Index"); } Product _item = new Product { Id = Id, Name = "Data" }; return View("Details", _item); }