public void CheckDelete_WithIdNull_ReturnNotFound() { FilmsController controller = new FilmsController(repos.Object); var res = controller.Delete(null) as NotFoundResult; Assert.AreEqual(404, res.StatusCode); }
public void CheckDelete_AnExistigFilm_ReturnDeleteView() { repos.Setup(m => m.getFilmById(1)).Returns(films.Find(x => x.ID == 1)); FilmsController controller = new FilmsController(repos.Object); var res = controller.Delete(1) as ViewResult; Assert.AreEqual("Delete", res.ViewName); }
public void ShouldDeleteFilm() { FilmsController controller = new FilmsController(); controller.Delete(2); var result = controller.Get(2) as OkNegotiatedContentResult <Film>; Assert.IsNull(result); }
public void CheckDelete_AnUnexistigFilm_ReturnNotFound() { Film film5 = null; repos.Setup(m => m.getFilmById(5)).Returns(film5); FilmsController controller = new FilmsController(repos.Object); var res = controller.Delete(5) as NotFoundResult; Assert.AreEqual(404, res.StatusCode); }
public async Task DeleteFilmThatDoesntExists() { var film1 = new Film() { Title = "Godfather" }; var film2 = new Film() { Title = "Godfellas" }; var service = new Mock <IFilmRepository>(); service.Setup(x => x.GetFilm(1)).ReturnsAsync(film1); service.Setup(x => x.GetFilm(2)).ReturnsAsync(film2); var controller = new FilmsController(service.Object); var result = await controller.Delete(100); var viewResult = (ViewResult)result; Assert.AreEqual("NotFound", viewResult.ViewName); }
public async Task DeleteExistingFilm() { var film1 = new Film() { Title = "Godfather" }; var film2 = new Film() { Title = "Godfellas" }; var service = new Mock <IFilmRepository>(); service.Setup(x => x.GetFilm(1)).ReturnsAsync(film1); service.Setup(x => x.GetFilm(2)).ReturnsAsync(film2); var controller = new FilmsController(service.Object); var result = await controller.Delete(1); var model = ((ViewResult)result).Model as Film; Assert.AreEqual(film1, model); }