public void EditTripShouldReturnView() { TripController controller = new TripController(repo); Trip trip4 = new Trip() { TripID = 4, DestinationID = 3, StartDate = new DateTime(2005, 3, 1), EndDate = new DateTime(2005, 3, 4)}; ViewResult result = controller.EditTrip(trip4) as ViewResult; Assert.IsNotNull(result); }
public void DeleteTripShouldRemoveTrip() { TripController controller = new TripController(repo); controller.DeleteTrip(trip2); ViewResult result = controller.Trips() as ViewResult; Assert.IsNotNull(result); IEnumerable<Trip> model = result.Model as IEnumerable<Trip>; Assert.AreEqual(1, model.Count()); Assert.IsFalse(model.Contains(trip2)); }
public void EditTripInDatabaseShouldChangePreviouslyAddedTrip() { TripController controller = new TripController(repo); Trip trip2changed = new Trip() { TripID = 2, DestinationID = 1, StartDate = new DateTime(2013, 12, 1), EndDate = new DateTime(2013, 12, 3) }; controller.EditTripInDatabase(trip2changed); ViewResult result = controller.Trips() as ViewResult; Assert.IsNotNull(result); IEnumerable<Trip> model = result.Model as IEnumerable<Trip>; Assert.AreEqual(2, model.Count()); Trip temp = model.ElementAt(1); Assert.AreEqual(trip2changed.TripID, temp.TripID); Assert.AreEqual(trip2changed.DestinationID, temp.DestinationID); Assert.AreEqual(trip2changed.StartDate, temp.StartDate); Assert.AreEqual(trip2changed.EndDate, temp.EndDate); }
public void Index_returns_list_of_correct_Trips() { TripController controller = new TripController(repository, provider); ViewResult result = controller.Index() as ViewResult; Assert.IsNotNull(result); EnumerableQuery<Trip> model = (EnumerableQuery<Trip>)result.ViewData.Model; Assert.IsNotNull(model); Assert.AreEqual(1, model.Count()); Assert.IsTrue(model.Contains(userTrip)); }
public void Edit_Trip_returns_Correct_Trip() { TripController controller = new TripController(repository, provider); ViewResult result = controller.Edit(userTrip.TripID) as ViewResult; Trip model = result.Model as Trip; Assert.AreEqual(model, userTrip); }
public void Edit_edits_correct_Trip() { TripController controller = new TripController(repository, provider); userTrip.description = "My editted trip"; userTrip.destination = "No where"; controller.Edit(userTrip); ViewResult result = controller.Index() as ViewResult; IQueryable<Trip> model = result.Model as IQueryable<Trip>; Assert.AreEqual(1, model.Count()); Assert.IsTrue(model.Contains(userTrip)); }
public void Details_should_not_work_for_nonexsistent_Trip() { TripController controller = new TripController(repository, provider); ViewResult result = controller.Details(Guid.NewGuid()) as ViewResult; Trip model = result.Model as Trip; }
public void Details_should_not_give_details_for_other_user_trips() { TripController controller = new TripController(notUserRepository, provider); ViewResult result = controller.Details(notUserTrip.TripID) as ViewResult; Trip model = result.Model as Trip; }
public void Cannot_Delete_nonexistent_Trip() { TripController controller = new TripController(repository, provider); ViewResult result = controller.Delete(Guid.NewGuid()) as ViewResult; Trip model = result.Model as Trip; }
public void Create_trip_adds_to_repository() { TripController controller = new TripController(repository, provider); Trip newTrip = new Trip(provider.AuthenticatedUser.UserID); newTrip.current_weight = 8; newTrip.description = "London Trip"; newTrip.destination = "London"; newTrip.total_capacity = 12; newTrip.weather = "Cloudy"; controller.Create(newTrip); ViewResult result = controller.Index() as ViewResult; IQueryable<Trip> model = result.Model as IQueryable<Trip>; Assert.IsTrue(model.Contains(newTrip)); Assert.AreEqual(2, model.Count()); }
public void Create_should_return_view() { TripController controller = new TripController(repository, provider); ViewResult result = controller.Create() as ViewResult; Assert.IsNotNull(result); }
public void Cannot_Edit_Post_changes_to_other_users_trips() { TripController controller = new TripController(notUserRepository, provider); notUserTrip.description = "Editted Trip"; controller.Edit(notUserTrip); ViewResult result = controller.Index() as ViewResult; IQueryable<Trip> model = result.Model as IQueryable<Trip>; }
public void TripsShouldListCorrectTrips() { TripController controller = new TripController(repo); ViewResult result = controller.Trips() as ViewResult; IEnumerable<Trip> model = result.Model as IEnumerable<Trip>; Assert.AreEqual(2, model.Count()); Assert.IsTrue(model.Contains(trip1)); Assert.IsTrue(model.Contains(trip2)); }
public void shouldAddNewTripToRepository() { TripController controller = new TripController(repo); Trip trip3 = new Trip() { TripID = 3, DestinationID = 1, StartDate = new DateTime(2013, 1, 1), EndDate = new DateTime(2013, 2, 1)}; controller.AddTrip(trip3); ViewResult result = controller.Trips() as ViewResult; Assert.IsNotNull(result); IEnumerable<Trip> model = result.Model as IEnumerable<Trip>; Assert.AreEqual(3, model.Count()); Assert.IsTrue(model.Contains(trip3)); }
public void Cannot_DeleteConfirmed_nonexistent_Trip() { TripController controller = new TripController(repository, provider); ViewResult result = controller.DeleteConfirmed(Guid.NewGuid()) as ViewResult; IQueryable<Trip> model = result.Model as IQueryable<Trip>; }
public void DeleteConfirmed_deletes_correct_Trip() { TripController controller = new TripController(repository, provider); controller.DeleteConfirmed(userTrip.TripID); ViewResult result = controller.Index() as ViewResult; IQueryable<Trip> model = result.Model as IQueryable<Trip>; Assert.IsFalse(model.Contains(userTrip)); Assert.AreEqual(0, model.Count()); }
public void Cannot_DeleteConfirmed_other_user_trips() { TripController controller = new TripController(notUserRepository, provider); ViewResult result = controller.DeleteConfirmed(notUserTrip.TripID) as ViewResult; IQueryable<Trip> model = result.Model as IQueryable<Trip>; }
public void Delete_returns_correct_Trip() { TripController controller = new TripController(repository, provider); ViewResult result = controller.Delete(userTrip.TripID) as ViewResult; Trip model = result.Model as Trip; Assert.AreEqual(userTrip, model); }
public void Cannot_Delete_other_user_trips() { TripController controller = new TripController(notUserRepository, provider); ViewResult result = controller.Delete(notUserTrip.TripID) as ViewResult; Trip model = result.Model as Trip; }
public void AddTripShouldReturnView() { TripController controller = new TripController(repo); ViewResult result = controller.AddTrip() as ViewResult; Assert.IsNotNull(result); }