public async Task <List <Discussion> > GetDiscussions(string movieid) { List <Repository.Models.Discussion> repoDiscussions = await _repo.GetMovieDiscussions(movieid); if (repoDiscussions == null) { Console.WriteLine("ForumLogic.GetDiscussions() was called with a movieid that doesn't exist."); return(null); } List <Discussion> discussions = new List <Discussion>(); foreach (var repoDiscussion in repoDiscussions) { // Get the topic associated with this discussion Repository.Models.Topic topic = _repo.GetDiscussionTopic(repoDiscussion.DiscussionId); if (topic == null) { topic = new Repository.Models.Topic(); topic.TopicName = "None"; } discussions.Add(Mapper.RepoDiscussionToDiscussion(repoDiscussion, topic)); } return(discussions); }
public async Task NoMovieGetMovieDiscussionsTest() { 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 GetMovieDiscussions() without Movie dependency result = await repoLogic.GetMovieDiscussions(dataSetA.Movie.MovieId); } Assert.Null(result); }