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, "");
        }
Esempio n. 3
0
        public void DetailsView()
        {
            string Search_Data = "Avatar";

            MovieController movieController = new MovieController();
            // Act
            ViewResult result = movieController.Details(Search_Data) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Esempio n. 4
0
        public void Details()
        {
            // Arrange
            MovieController controller = new MovieController();

            // Act
            ViewResult result = controller.Details(1) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        public void Details_Has_A_View()
        {
            var result = underTest.Details(1);

            Assert.IsType <ViewResult>(result);
        }