Example #1
0
        public void AddMovie_ShouldThrow_WhenMovieIsAlreadyThere()
        {
            var db = new TFContext(this.DatabaseSimulator());
            var genreServicesMock = new Mock <IGenreServices>();
            var actorServicesMock = new Mock <IActorServices>();
            var movieService      = new AddMovieService
                                        (db, genreServicesMock.Object, actorServicesMock.Object);

            Movie movieToAdd = new Movie
            {
                ApiMovieId = apiMovieIdToUse,
                Title      = movieTitle
            };

            movieService.AddMovie(movieToAdd);

            Assert.ThrowsException <EntityAlreadyExistingException>(() => movieService.AddMovie(movieToAdd));
        }
Example #2
0
        public void AddMovie_Should_RestoreActor()
        {
            var db = new TFContext(this.DatabaseSimulator());
            var genreServicesMock = new Mock <IGenreServices>();
            var actorServicesMock = new Mock <IActorServices>();
            var movieService      = new AddMovieService
                                        (db, genreServicesMock.Object, actorServicesMock.Object);

            Movie movieToAdd = new Movie
            {
                ApiMovieId = apiMovieIdToUse,
                Title      = movieTitle
            };

            movieService.AddMovie(movieToAdd);

            movieToAdd.IsDeleted = true;

            movieService.AddMovie(movieToAdd);

            Assert.IsFalse(movieToAdd.IsDeleted);
        }
Example #3
0
        public void AddMovie_Should_AddMovieWhenItIsCorrect()
        {
            var db = new TFContext(this.DatabaseSimulator());
            var genreServicesMock = new Mock <IGenreServices>();
            var actorServicesMock = new Mock <IActorServices>();
            var movieService      = new AddMovieService
                                        (db, genreServicesMock.Object, actorServicesMock.Object);

            var movieToAdd = new Movie()
            {
                ApiMovieId = apiMovieIdToUse,
                Title      = movieTitle
            };

            var result = movieService.AddMovie(movieToAdd);

            Assert.AreEqual(movieTitle, result.Title);
            Assert.AreEqual(apiMovieIdToUse, result.ApiMovieId);
        }