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); }
public async Task NoUserUpdateUserTest() { bool result; Repository.Models.User updatedRepoUser = new Repository.Models.User(); RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory"); updatedRepoUser.Username = dataSetA.User.Username; updatedRepoUser.FirstName = "Steve"; updatedRepoUser.LastName = dataSetA.User.LastName; updatedRepoUser.Email = dataSetA.User.Email; updatedRepoUser.Permissions = dataSetA.User.Permissions; updatedRepoUser.Username = dataSetA.User.Username; using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); RepoLogic repoLogic = new RepoLogic(context); // Test UpdateUser() without User dependency result = await repoLogic.UpdateUser(dataSetA.User.Username, updatedRepoUser); } Assert.False(result); }
public async Task PatchExistingMovieTest() { MovieDTO inputMovie = TestingHelper.GetRandomMovie(); Movie outputMovie; // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); // Test AppendMovie() await movieController.AppendMovie(inputMovie.ImdbId, TestingHelper.GetRandomMovie()); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { outputMovie = context.Movies.FirstOrDefault(m => m.ImdbId == inputMovie.ImdbId); } Assert.NotEqual(inputMovie.Title, outputMovie.Title); }
public void GetTagsTest() { MovieDTO inputMovie = TestingHelper.GetRandomMovie(0, 0, 0, 0, 3); List <string> results; // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); // Test GetAllTags() results = movieController.GetAllTags().Value; } Assert.Contains(inputMovie.MovieTags[0], results); Assert.Contains(inputMovie.MovieTags[1], results); Assert.Contains(inputMovie.MovieTags[2], results); }
public async Task MovieTest() { string inputMovieId = "ab10101010"; string outputMovieId; // Seed the test database using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); RepoLogic repoLogic = new RepoLogic(context); // Test CreateMovie() IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); await movieController.CreateMovie(inputMovieId); } using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { var gmMovie = context.Movies.FirstOrDefault <Repository.Models.Movie>(m => m.MovieId == inputMovieId); outputMovieId = gmMovie.MovieId; } Assert.Equal(inputMovieId, outputMovieId); }
public async Task TopicTest() { RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory"); string outputTopicName; // Seed the test database using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.Topics.Add(dataSetA.Topic); context.SaveChanges(); } using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); IForumLogic forumLogic = new ForumLogic(repoLogic); ForumController forumController = new ForumController(forumLogic); List <string> topicNames = (await forumController.GetTopics()).Value; outputTopicName = topicNames[0]; } Assert.Equal(dataSetA.Topic.TopicName, outputTopicName); }
public void DeleteMovieTest() { MovieDTO inputMovie = TestingHelper.GetRandomMovie(); Movie outputMovie; using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); // Test DeleteMovie() movieController.DeleteMovie(inputMovie.ImdbId); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { outputMovie = context.Movies.FirstOrDefault(m => m.ImdbId == inputMovie.ImdbId); } Assert.Null(outputMovie); }
public void UnbanTagTest() { var inputMovie = TestingHelper.GetRandomMovie(); var inputTag = TestingHelper.GetRandomTaggingDTO(inputMovie.ImdbId); bool inputBanState = true; Tag tag; // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); TestingHelper.AddTagToDatabase(context, inputTag, inputBanState); RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); // Test UnbanTag() movieController.UnbanTag(inputTag.TagName); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { tag = context.Tags.FirstOrDefault(t => t.TagName == inputTag.TagName); } Assert.False(tag.IsBanned); }
public void SearchActorTagTest() { MovieDTO inputMovie = TestingHelper.GetRandomMovie(1, 1, 1, 1, 1); MovieDTO unmatchedMovie = TestingHelper.GetRandomMovie(1, 1, 1, 1, 1); unmatchedMovie.MovieActors[0] = inputMovie.MovieActors[0]; List <string> searchResults; var filters = new Dictionary <string, string[]>(); filters.Add("Actor", new string[] { inputMovie.MovieActors[0] }); filters.Add("Tag", new string[] { inputMovie.MovieTags[0] }); // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); TestingHelper.AddMovieDTOToDatabase(context, unmatchedMovie); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); // Test SearchMovies() searchResults = movieController.SearchMovies(filters).Value; } Assert.Equal(inputMovie.ImdbId, searchResults[0]); }
public async Task PostTagTest() { var inputMovie = TestingHelper.GetRandomMovie(); var inputTag = TestingHelper.GetRandomTaggingDTO(inputMovie.ImdbId); MovieTagUser movieTagUser; // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); // Test TagMovie() await movieController.TagMovie(inputTag); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { movieTagUser = context.MovieTagUsers.FirstOrDefault(m => m.ImdbId == inputTag.MovieId); } Assert.Equal(inputTag.MovieId, movieTagUser.ImdbId); Assert.Equal(inputTag.TagName, movieTagUser.TagName); Assert.Equal(inputTag.UserId, movieTagUser.UserId); }
public async Task GetMovieTest() { MovieDTO inputMovie = TestingHelper.GetRandomMovie(); MovieDTO outputMovie; // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); // Test GetMovie() outputMovie = (await movieController.GetMovie(inputMovie.ImdbId)).Value; } Assert.Equal(inputMovie.ImdbId, outputMovie.ImdbId); }
public void SearchRatingTest() { MovieDTO inputMovie = TestingHelper.GetRandomMovie(0, 0, 0, 0, 0); List <string> searchResults; var filters = new Dictionary <string, string[]>(); Console.WriteLine(inputMovie); filters.Add("Rating", new string[] { inputMovie.RatingName }); // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); TestingHelper.AddMovieDTOToDatabase(context, TestingHelper.GetRandomMovie(0, 0, 0, 0, 0)); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); MovieController movieController = new MovieController(movieLogic); // Test SearchMovies() searchResults = movieController.SearchMovies(filters).Value; } Assert.Equal(inputMovie.ImdbId, searchResults[0]); }
public void DeleteFollowedMovieTest() { var dbOptions = TestingHelper.GetUniqueContextOptions <Cinephiliacs_MovieContext>(); MovieDTO inputMovie = TestingHelper.GetRandomMovie(); string userId = Guid.NewGuid().ToString(); List <string> followedMovies; // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); // Test FollowMovie() movieLogic.FollowMovie(inputMovie.ImdbId, userId); movieLogic.UnfollowMovie(inputMovie.ImdbId, userId); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); IMovieLogic movieLogic = new MovieLogic(repoLogic); // Test FollowMovie() followedMovies = movieLogic.GetFollowingMovies(userId); } Assert.DoesNotContain(inputMovie.ImdbId, followedMovies); }
public async Task AddUserTwice() { bool result; 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(); GlobalModels.User inputGMUser = BusinessLogic.Mapper.RepoUserToUser(dataSetA.User); RepoLogic repoLogic = new RepoLogic(context); // Test CreateUser() IUserLogic userLogic = new UserLogic(repoLogic); UserController userController = new UserController(userLogic); await userController.CreateUser(inputGMUser); } using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); // Test AddUser() result = await repoLogic.AddUser(dataSetA.User); } Assert.False(result); }
public async Task RecommendedMoviesByUserIdTest() { MovieDTO inputMovie = TestingHelper.GetRandomMovie(); inputMovie.ImdbId = "tt4154796"; string userId = Guid.NewGuid().ToString(); List <MovieDTO> results; // Seed the test database using (var context = new Cinephiliacs_MovieContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); TestingHelper.AddMovieDTOToDatabase(context, inputMovie); var followingMovie = new FollowingMovie(); followingMovie.ImdbId = inputMovie.ImdbId; followingMovie.UserId = userId; context.FollowingMovies.Add(followingMovie); context.SaveChanges(); } using (var context = new Cinephiliacs_MovieContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); MovieLogic movieLogic = new MovieLogic(repoLogic); // Test RecommendedMoviesByUserId() results = await movieLogic.RecommendedMoviesByUserId(userId); } Assert.True(results.Count > 0); }
public void TestAddMovieDirector() { var sut = new MovieDirector() { ImdbId = "12345", DirectorId = Guid.NewGuid(), Director = new Director() { DirectorId = Guid.NewGuid(), DirectorName = "Anis" }, Imdb = new Movie() { ImdbId = "12345", Title = "Titanic" } }; bool result; using (var context2 = new Cinephiliacs_MovieContext(dbOptions)) { context2.Database.EnsureCreated(); var msr = new RepoLogic(context2); result = msr.AddMovieActor(sut.Imdb.ImdbId, sut.Director.DirectorName); } Assert.False(result); }
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); }
public void TestAddMovieTagUser() { var sut1 = new MovieTagUser() { ImdbId = "Anis", TagName = "Bad", UserId = "12345", IsUpvote = true }; MovieTagUser result1; using (var context2 = new Cinephiliacs_MovieContext(dbOptions)) { context2.Database.EnsureCreated(); var msr = new RepoLogic(context2); msr.AddMovieTagUser(sut1); result1 = context2.MovieTagUsers.FirstOrDefault(ma => ma.ImdbId == "Anis"); } Assert.Equal("Anis", result1.ImdbId); }
public async Task UserTest() { GlobalModels.User updatedGMUser = new GlobalModels.User(); RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory"); updatedGMUser.Username = dataSetA.User.Username; updatedGMUser.Firstname = "Steve"; updatedGMUser.Lastname = dataSetA.User.LastName; updatedGMUser.Email = dataSetA.User.Email; updatedGMUser.Permissions = dataSetA.User.Permissions; updatedGMUser.Username = dataSetA.User.Username; string inputFirstName = dataSetA.User.FirstName; string outputFirstName; // Seed the test database using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); RepoLogic repoLogic = new RepoLogic(context); // Test CreateUser & UpdateUser() IUserLogic userLogic = new UserLogic(repoLogic); UserController userController = new UserController(userLogic); await userController.CreateUser(BusinessLogic.Mapper.RepoUserToUser(dataSetA.User)); await userController.UpdateUser(dataSetA.User.Username, updatedGMUser); } using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); // Test GetUser() IUserLogic userLogic = new UserLogic(repoLogic); UserController userController = new UserController(userLogic); outputFirstName = userController.GetUser(dataSetA.User.Username).Value.Firstname; } Assert.NotEqual(inputFirstName, outputFirstName); }
public void NoDiscGetDiscussionTopicTest() { object 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); // Test GetDiscussionTopic() without Discussion dependency result = repoLogic.GetDiscussionTopic(dataSetA.DiscussionTopic.DiscussionId); } Assert.Null(result); }
public async Task NoMovieGetMovieReviewsTest() { object 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); // Test GetMovieReviews() without Movie dependency result = await repoLogic.GetMovieReviews(dataSetA.Movie.MovieId); } Assert.Null(result); }
public async Task NoUserAddDiscussionTest() { 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); // Test AddDiscussion() without User dependency result = await repoLogic.AddDiscussion(dataSetA.Discussion, dataSetA.Topic); } Assert.False(result); }
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); }
public async Task NoMovieAddReviewTest() { 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); // Test AddReview() without Movie dependency result = await repoLogic.AddReview(dataSetA.Review); } Assert.False(result); }
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); }
public async Task UsersTest() { GlobalModels.User inputGMUser; GlobalModels.User outputGMUser; 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(); inputGMUser = BusinessLogic.Mapper.RepoUserToUser(dataSetA.User); RepoLogic repoLogic = new RepoLogic(context); // Test CreateUser() IUserLogic userLogic = new UserLogic(repoLogic); UserController userController = new UserController(userLogic); await userController.CreateUser(inputGMUser); } using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions)) { RepoLogic repoLogic = new RepoLogic(context); // Test GetUsers() IUserLogic userLogic = new UserLogic(repoLogic); UserController userController = new UserController(userLogic); List <GlobalModels.User> gmUserList = (await userController.Get()).Value; outputGMUser = gmUserList .FirstOrDefault <GlobalModels.User>(u => u.Username == dataSetA.User.Username); } Assert.Equal(inputGMUser, outputGMUser); }
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); }
public UserLogic(RepoLogic repo) { _repo = repo; }
public MovieLogic(RepoLogic repo) { _repo = repo; }
public UserLogic(RepoLogic repo, ILogger <UserLogic> logger) { _repo = repo; _logger = logger; }