public void view_details_OK() { //Arrange var controller = new MovieController(new MovieBLL(new MovieRepositoryStub())); var expected_result = new Movie() { Id = 1, ImageAddress = "movieImageAddress.jpg", Title = "Title", Description = "Blockbaster", Price = 12, Genre = "Fantasy" }; //Act var actionResult = (ViewResult)controller.Details(1); var result = (Movie)actionResult.Model; //Assert Assert.AreEqual(actionResult.ViewName, ""); Assert.AreEqual(expected_result.Id, result.Id); Assert.AreEqual(expected_result.ImageAddress, result.ImageAddress); Assert.AreEqual(expected_result.Title, result.Title); Assert.AreEqual(expected_result.Description, result.Description); Assert.AreEqual(expected_result.Price, result.Price); Assert.AreEqual(expected_result.Genre, result.Genre); }
public void details_Fail() { //Arrange var controller = new MovieController(new MovieBLL(new MovieRepositoryStub())); //Act var actionResult = (ViewResult)controller.Details(0); //Assert Assert.AreEqual(actionResult.ViewName, ""); }
public void DetailsView() { string Search_Data = "Avatar"; MovieController movieController = new MovieController(); // Act ViewResult result = movieController.Details(Search_Data) as ViewResult; // Assert Assert.IsNotNull(result); }
public void Details() { // Arrange MovieController controller = new MovieController(); // Act ViewResult result = controller.Details(1) as ViewResult; // Assert Assert.IsNotNull(result); }
public async Task Return404_WhenMovieNotFoundExceptionIsThrown() { //Arrange const int movieID = 3; var movieServiceMock = new Mock <IMovieServices>(); movieServiceMock .Setup(ms => ms.CheckMovieAsync(movieID)) .Callback(() => throw new MovieNotFoundException()); var movieCachMock = new Mock <IMemoryCache>(); var userManagerMock = new Mock <IUserManager <User> >(); var sut = new MovieController(movieServiceMock.Object, movieCachMock.Object, userManagerMock.Object); //Act var result = await sut.Details(movieID); //Assert Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }
public async Task ReturnCorrectViewModel_OnGet() { // Arrange var movieServiceMock = new Mock <IMovieService>(); var genreServiceMock = new Mock <IGenreService>(); string movieName = "Spiderman"; movieServiceMock .Setup(g => g.GetMovieByNameAsync(movieName)) .ReturnsAsync(new MovieViewModel()); var sut = new MovieController(movieServiceMock.Object, genreServiceMock.Object); // Act var result = await sut.Details(movieName) as ViewResult; // Assert Assert.IsInstanceOfType(result.Model, typeof(MovieViewModel)); }
public async Task CallMovieServiceOnce_OnGet() { // Arrange var movieServiceMock = new Mock <IMovieService>(); var genreServiceMock = new Mock <IGenreService>(); string movieName = "Spiderman"; movieServiceMock .Setup(g => g.GetMovieByNameAsync(movieName)) .ReturnsAsync(new MovieViewModel()); var sut = new MovieController(movieServiceMock.Object, genreServiceMock.Object); // Act await sut.Details(movieName); // Assert movieServiceMock.Verify(g => g.GetMovieByNameAsync(movieName), Times.Once); }
public async Task ReturnsCorrectViewResult() { //Arrange const int movieID = 3; var movieServiceMock = new Mock <IMovieServices>(); movieServiceMock .Setup(ms => ms.CheckMovieAsync(movieID)) .ReturnsAsync(new Movie { Director = new Director(), MovieGenres = new List <MovieGenre>(), Reviews = new List <Review>() }); var movieCachMock = new Mock <IMemoryCache>(); var userManagerMock = new Mock <IUserManager <User> >(); var sut = new MovieController(movieServiceMock.Object, movieCachMock.Object, userManagerMock.Object); //Act var result = await sut.Details(movieID); //Assert Assert.IsInstanceOfType(result, typeof(ViewResult)); }
public async Task CallCorrectServiceMethod() { //Arrange const int movieID = 3; var movieServiceMock = new Mock <IMovieServices>(); movieServiceMock .Setup(ms => ms.CheckMovieAsync(movieID)) .ReturnsAsync(new Movie { Director = new Director(), MovieGenres = new List <MovieGenre>(), Reviews = new List <Review>() }); var movieCachMock = new Mock <IMemoryCache>(); var userManagerMock = new Mock <IUserManager <User> >(); var sut = new MovieController(movieServiceMock.Object, movieCachMock.Object, userManagerMock.Object); //Act var result = await sut.Details(movieID) as ViewResult; //Assert movieServiceMock.Verify(s => s.CheckMovieAsync(movieID), Times.Once); }
public void Details_Has_A_View() { var result = underTest.Details(1); Assert.IsType <ViewResult>(result); }