public void IT_DbFilmRepository() { IFilmRepository sut = new EfFilmRepository(); Assert.AreEqual(5, sut.SelectAll().Count(), "assertion 1"); Assert.AreEqual(4, sut.SearchByTitle("the").Count(), "assertion 2"); Film film1 = new Film("Aliens", new DateTime(1984, 1, 20), 5, Genre.Science_Fiction); Film film2 = new Film("The Matrix", new DateTime(1999, 5, 18), 2, Genre.Science_Fiction); //act long id1 = sut.Insert(film1); long id2 = sut.Insert(film2); Assert.AreEqual(film1.Title, sut.SelectById(id1).Title, "assertion 3"); Assert.AreEqual(film2.Title, sut.SelectById(id2).Title, "assertion 4"); film1 = sut.SelectById(id1); film1.Stock = 0; sut.Update(film1); Assert.AreEqual(0, sut.SelectById(id1).Stock, "assertion 5"); sut.Delete(film2); Assert.IsNull(sut.SelectById(id2), "assertion 6"); }
public ActionResult Create(Film newFilm) { if (ModelState.IsValid) { EfFilmRepository repo = new EfFilmRepository(); repo.Insert(newFilm); return(RedirectToAction("List")); } else { return(RedirectToAction("Create")); } }