public void GetCommentIdByPhotoIdShouldWorkCorrectly() { var comments = new List <Comment>(); var mockCommentRepo = new Mock <IDeletableEntityRepository <Comment> >(); mockCommentRepo.Setup(x => x.All()).Returns(comments.AsQueryable()); mockCommentRepo.Setup(x => x.AddAsync(It.IsAny <Comment>())).Callback((Comment comm) => comments.Add(comm)); var service = new CommentsService(mockCommentRepo.Object, null, null); var comment = new Comment { Id = "1", UserId = "1", SentById = "1", PhotoId = "1", Content = "Xaxaxa", }; comments.Add(comment); var commentId = service.GetCommentIdByPhotoId("1"); Assert.Equal(comment.Id, commentId); }