public async Task CreateDiscussionAddsCorrectly() { // Arrange var commentsList = this.GetComments(); var discussionList = this.GetDiscussions(); var expectedComments = commentsList.Count() + 1; var expectedDiscussion = discussionList.Count() + 1; var mediaList = this.GetMedias(); var media = mediaList.FirstOrDefault().Id; var mediaRepoMock = new Mock <IRepository <Media> >(); var mock = mediaList.AsQueryable().BuildMock(); mediaRepoMock.Setup(x => x.AllAsNoTracking()).Returns(mock.Object); var commentsRepoMock = this.GetCommentMock(commentsList).Object; var discussionRepoMock = this.GetDiscussionMock(discussionList).Object; var commentService = new DiscussionsService(discussionRepoMock, commentsRepoMock, this.commentVoteRepo, mediaRepoMock.Object); var inputModel = new DiscussionInputModel() { Content = "Hell yeah", MediaId = media, Title = "Yes", }; // Act await commentService.CreateDiscussion(inputModel, ""); // Assert Assert.Equal(expectedComments, commentsRepoMock.AllAsNoTracking().Count()); Assert.Equal(expectedDiscussion, discussionRepoMock.AllAsNoTracking().Count()); Assert.Contains(discussionRepoMock.AllAsNoTracking().ToList(), x => x.MediaId == inputModel.MediaId && x.Title == inputModel.Title); Assert.Contains(commentsRepoMock.AllAsNoTracking().ToList(), x => x.Content == inputModel.Content); }