public void TestAddMovieWithStarringActors()
        {
            var newMovieVm = ViewModelMocks.MovieVmWithStarringActors;

            _moviesController.AddMovie(newMovieVm);

            var addedMovie = _context.Set <Movie>().AsEnumerable().Last();

            Assert.IsTrue(newMovieVm.Equals(addedMovie));
        }
        public async Task GivenAValidMovie_WhenIPostAnInvalidMovie_ThenItReturnsbadRequest()
        {
            _mockMovieRepository = new Mock <IMovieRepository>();
            _mockMovieMapper     = new Mock <IMapper>();
            _mockMovieMapper.Setup(mapper => mapper.Map <TblMovie>(It.IsAny <MovieForDetailedDto>()))
            .Returns(new TblMovie());
            _mockMovieRepository.Setup(repo => repo.AddMovie(It.IsAny <TblMovie>()))
            .ReturnsAsync((TblMovie movie) => movie);
            _moviesController = new MoviesController(_mockMovieRepository.Object, _mockMovieMapper.Object);
            var tblMovie = await _moviesController.AddMovie(new MovieForDetailedDto
            {
                //AMovieId = 3,
                //ATitle = "Big Hero 6",
                AMovieDescription = "An action comedy adventure about brilliant robotics prodigy Hiro Hamada, who finds himself in the grips of a criminal plot that threatens to destroy the fast-paced, high-tech city of San Fransokyo. With the help of his closest companion-a robot named Baymax-Hiro joins forces with a reluctant team of first-time crime fighters on a mission to save their city.",
                ADuration         = "105 min",
                APrice            = "10",
                APurchasePrice    = "25",
                ARating           = 5,
                AImageLink        = "http://upload.wikimedia.org/wikipedia/en/4/4b/Big_Hero_6_%28film%29_poster.jpg",
                ATrailerLink      = "//www.youtube.com/embed/z3biFxZIJOQ",
                AGenre            = "Comedy",
                AWideImage        = "https://github.com/tushar23091998/MovieRentalApp-FrontEnd/blob/master/src/app/images/bighero6.jpg?raw=true"
            });

            Assert.IsInstanceOf <BadRequestObjectResult>(tblMovie);
        }
        public void AddMovie_CallWithModelValidationError_ShouldReturnBadRequestObjectResult()
        {
            // Arrange
            MovieDto movieWithMissingTitle = new MovieDto()
            {
                // Title is missing
                Duration = 130,
                Year     = 1999
            };

            _moviesController.ModelState.AddModelError("Title", "Required");

            // Act
            var badResponse = _moviesController.AddMovie(movieWithMissingTitle);

            // Assert
            Assert.IsInstanceOfType(badResponse.Result, typeof(BadRequestObjectResult));
        }