Beispiel #1
0
        public void ClearRating_WithValidMovieId_CallsSaveOnMovieRepository()
        {
            IMembershipService membershipService = new FakeMembershipService(Enumerable.Empty <MembershipUser>());

            var       movies  = new List <Movie>();
            const int movieId = 42;
            var       movie   = new Movie
            {
                Id        = movieId,
                Directors = "Directors",
                GenreId   = 1,
                Name      = "Name",
                Rating    = 3,
                Stars     = "Stars",
                Writers   = "Writers"
            };

            movies.Add(movie);

            bool   wasCalled  = false;
            Action saveAction = () => wasCalled = true;

            IRepository <Movie> movieRepository = new FakeMovieRepository(movies, saveCallback: saveAction);
            IRepository <Genre> genreRepository = new FakeGenreRepository();
            var movieController = new MovieController(movieRepository, genreRepository, membershipService)
            {
                ControllerContext = new FakeControllerContext()
            };


            movieController.ClearRating(movieId);

            Assert.IsTrue(wasCalled);
        }
Beispiel #2
0
        public void ClearRating_WithValidMovieId_ClearsRatingOnMovie()
        {
            IMembershipService membershipService = new FakeMembershipService(Enumerable.Empty <MembershipUser>());

            var       movies  = new List <Movie>();
            const int movieId = 42;
            var       movie   = new Movie
            {
                Id        = movieId,
                Directors = "Directors",
                GenreId   = 1,
                Name      = "Name",
                Rating    = 3,
                Stars     = "Stars",
                Writers   = "Writers"
            };

            movies.Add(movie);


            IRepository <Movie> movieRepository = new FakeMovieRepository(movies);
            IRepository <Genre> genreRepository = new FakeGenreRepository();
            var movieController = new MovieController(movieRepository, genreRepository, membershipService);


            movieController.ClearRating(movieId);

            Assert.IsTrue(movie.Rating == 0);
        }