public void ThenReturnTheFlightViewModel() { // Arrange var flights = new List <FlightWeb.Models.Flight>() { new FlightWeb.Models.Flight { FlightId = 1, Departure = "Orly", Destination = "Paris" }, new FlightWeb.Models.Flight { FlightId = 2, Departure = "Paris", Destination = "Rouen" }, new FlightWeb.Models.Flight { FlightId = 3, Departure = "Nice", Destination = "Lyon" } }; var flightRepository = new Mock <ICustomRepository <FlightWeb.Models.Flight> >(); flightRepository.Setup(m => m.GetAllData()).Returns(flights.AsQueryable()); var controller = new FlightController(flightRepository.Object); // Act var result = controller.Index(null, null, null) as ViewResult; var model = result.Model as IEnumerable <FlightWeb.Models.Flight>; // Assert Assert.IsNotNull(result); Assert.AreEqual(3, model.Cast <Object>().Count()); }
public void Index() { // Arrange FlightController controller = new FlightController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.AreEqual("Modify this template to jump-start your ASP.NET MVC application.", result.ViewBag.Message); }