public void IndexViewData() { //Arrange// // Lets create our dummy repository UnitRepo = new DummyRentalRepositoryTest(_fakeUnits.MyUnits); // Now lets create the unitsController object to test and pass our unit of work Controller = new UnitRepositoryPatternController(UnitRepo); // act var actual = Controller.Index(); // assert var viewResult = actual as ViewResult; if (viewResult == null) return; var data = viewResult.ViewData.Model as IList<Unit>; if (data != null) { Assert.AreEqual(1, data.Count); } ///------View Name-------/// // var result = controller.Details(2) as ViewResult; //Assert.AreEqual("Details", result.ViewName); ///------View Name-------/// ///------Redirect to Action result-------/// //if (Id < 1) //return RedirectToAction("Index"); // var result = (RedirectToRouteResult) controller.Details(-1); // Assert.AreEqual("Index", result.Values["action"]); ///------Redirect to ActioN result-------/// }
public void Index() { //Arrange// // Lets create our dummy repository UnitRepo = new DummyRentalRepositoryTest(_fakeUnits.MyUnits); // Now lets create the unitsController object to test and pass our unit of work Controller = new UnitRepositoryPatternController(UnitRepo); // act var actual = Controller.Index(); // assert var viewResult = actual as ViewResult; if (viewResult == null) return; var data = viewResult.ViewData.Model as IList<Unit>; if (data != null) Assert.AreEqual(1, data.Count); }