public async Task FollowMovieTwiceTest()
        {
            bool result;

            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                RepoLogic repoLogic = new RepoLogic(context);
                await repoLogic.AddUser(dataSetA.User);

                await repoLogic.AddMovie(dataSetA.Movie.MovieId);

                await repoLogic.FollowMovie(dataSetA.FollowingMovie);
            }

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                RepoLogic repoLogic = new RepoLogic(context);

                // Test FollowMovie() a second time with same input
                result = await repoLogic.FollowMovie(dataSetA.FollowingMovie);
            }

            Assert.False(result);
        }
Exemple #2
0
        public async Task CommentsPageTest()
        {
            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            GlobalModels.Comment inputGMComment = BusinessLogic.Mapper.RepoCommentToComment(dataSetA.Comment);
            GlobalModels.Comment outputGMComment;

            // Seed the test database
            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var newComment = new GlobalModels.NewComment(inputGMComment);

                RepoLogic repoLogic = new RepoLogic(context);
                // Add Database entries for the object-under-test's foreign keys
                await repoLogic.AddUser(dataSetA.User);

                await repoLogic.AddMovie(dataSetA.Movie.MovieId);

                await repoLogic.AddDiscussion(dataSetA.Discussion, dataSetA.Topic);

                // Test CreateComment()
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);
                await forumController.CreateComment(newComment);
            }

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                RepoLogic repoLogic = new RepoLogic(context);

                // Test GetComments()
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);
                await forumController.SetCommentsPageSize(10);

                List <GlobalModels.Comment> gmCommentList = (await forumController.GetCommentsPage(dataSetA.Comment.DiscussionId, 1)).Value;
                outputGMComment = gmCommentList
                                  .FirstOrDefault <GlobalModels.Comment>(c => c.Discussionid == dataSetA.Comment.DiscussionId);
            }

            Assert.Equal(inputGMComment, outputGMComment);
        }
Exemple #3
0
        public async Task ReviewsPageTest()
        {
            GlobalModels.Review inputGMReview;
            GlobalModels.Review outputGMReview;

            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            // Seed the test database
            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                inputGMReview = BusinessLogic.Mapper.RepoReviewToReview(dataSetA.Review);

                RepoLogic repoLogic = new RepoLogic(context);
                // Load Database entries for the object-under-test's foreign keys
                await repoLogic.AddUser(dataSetA.User);

                await repoLogic.AddMovie(dataSetA.Movie.MovieId);

                // Test CreateReview()
                IMovieLogic     movieLogic      = new MovieLogic(repoLogic);
                MovieController movieController = new MovieController(movieLogic);
                await movieController.CreateReview(inputGMReview);
            }

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                RepoLogic repoLogic = new RepoLogic(context);

                // Test GetReviews()
                IMovieLogic     movieLogic      = new MovieLogic(repoLogic);
                MovieController movieController = new MovieController(movieLogic);
                await movieController.SetReviewsPageSize(10);

                List <GlobalModels.Review> gmReviewList = (await movieController.GetReviewsPage(dataSetA.Movie.MovieId, 1, "ratingasc")).Value;
                outputGMReview = gmReviewList
                                 .FirstOrDefault <GlobalModels.Review>(r => r.Movieid == dataSetA.Movie.MovieId);
            }

            Assert.Equal(inputGMReview, outputGMReview);
        }
Exemple #4
0
        public async Task GetDiscussionTest()
        {
            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            GlobalModels.Discussion inputGMDiscussion = BusinessLogic.Mapper.RepoDiscussionToDiscussion(dataSetA.Discussion, dataSetA.Topic);
            GlobalModels.Discussion outputGMDiscussion;

            // Seed the test database
            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var newDiscussion = new GlobalModels.NewDiscussion(inputGMDiscussion);

                RepoLogic repoLogic = new RepoLogic(context);
                // Add Database entries for the object-under-test's foreign keys
                await repoLogic.AddUser(dataSetA.User);

                await repoLogic.AddMovie(dataSetA.Movie.MovieId);

                await repoLogic.AddTopic(dataSetA.Topic);

                // Test CreateDiscussion()
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);
                await forumController.CreateDiscussion(newDiscussion);
            }

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                RepoLogic repoLogic = new RepoLogic(context);

                // Test GetDiscussions()
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);
                outputGMDiscussion = (await forumController.GetDiscussion(dataSetA.Discussion.DiscussionId)).Value;
            }

            Assert.Equal(inputGMDiscussion, outputGMDiscussion);
        }
Exemple #5
0
        public async Task FollowMovieTest()
        {
            string outputFollowingMovieId;

            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            // Seed the test database
            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                RepoLogic repoLogic = new RepoLogic(context);
                // Load Database entries for the object-under-test's foreign keys
                await repoLogic.AddUser(dataSetA.User);

                await repoLogic.AddMovie(dataSetA.Movie.MovieId);

                // Test FollowMovie()
                IUserLogic     userLogic      = new UserLogic(repoLogic);
                UserController userController = new UserController(userLogic);
                await userController.FollowMovie(dataSetA.FollowingMovie.Username, dataSetA.FollowingMovie.MovieId);
            }

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                RepoLogic repoLogic = new RepoLogic(context);

                // Test GetFollowingMovies()
                IUserLogic     userLogic          = new UserLogic(repoLogic);
                UserController userController     = new UserController(userLogic);
                List <string>  followingMovieList = (await userController.GetFollowingMovies(dataSetA.User.Username)).Value;
                outputFollowingMovieId = followingMovieList.FirstOrDefault <string>();
            }

            Assert.Equal(dataSetA.FollowingMovie.MovieId, outputFollowingMovieId);
        }
Exemple #6
0
        public async Task <bool> CreateMovie(MovieDTO movieDTO)
        {
            if (movieDTO.ImdbId == null || _repo.MovieExists(movieDTO.ImdbId))
            {
                return(false);
            }

            Movie movie = new Movie();

            movie.ImdbId = movieDTO.ImdbId;

            AppendMoviesOptionalProperties(movie, movieDTO);

            _repo.AddMovie(movie);

            var plotWords = SplitPlotIntoWords(movieDTO.Plot);

            await AutoTagMovie(plotWords, movieDTO.ImdbId);

            if (movieDTO.MovieActors != null)
            {
                foreach (var movieActorName in movieDTO.MovieActors)
                {
                    if (!_repo.AddMovieActor(movieDTO.ImdbId, movieActorName))
                    {
                        return(false);
                    }
                }
            }
            if (movieDTO.MovieDirectors != null)
            {
                foreach (var movieDirectorName in movieDTO.MovieDirectors)
                {
                    if (!_repo.AddMovieDirector(movieDTO.ImdbId, movieDirectorName))
                    {
                        return(false);
                    }
                }
            }
            if (movieDTO.MovieGenres != null)
            {
                foreach (var movieGenreName in movieDTO.MovieGenres)
                {
                    if (!_repo.AddMovieGenre(movieDTO.ImdbId, movieGenreName))
                    {
                        return(false);
                    }
                }
            }
            if (movieDTO.MovieLanguages != null)
            {
                foreach (var movieLanguageName in movieDTO.MovieLanguages)
                {
                    if (!_repo.AddMovieLanguage(movieDTO.ImdbId, movieLanguageName))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemple #7
0
 public async Task <bool> CreateMovie(string movieid)
 {
     return(await _repo.AddMovie(movieid));
 }