public async Task <List <Comment> > GetComments(string username) { List <Repository.Models.Comment> repoComments = await _repo.GetUserComments(username); if (repoComments == null) { Console.WriteLine("UserLogic.GetComments() was called for a username that doesn't exist."); return(null); } List <Comment> comments = new List <Comment>(); foreach (var repoComment in repoComments) { comments.Add(Mapper.RepoCommentToComment(repoComment)); } return(comments); }
public async Task NoUserGetCommentsTest() { 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 GetUserComments() without User dependency result = await repoLogic.GetUserComments(dataSetA.User.Username); } Assert.Null(result); }