public void TestGetVotesCount_ShouldReturnCorrectCounts() { var repository = new Mock <IRepository <Vote> >(); repository.Setup(r => r.All()).Returns(new List <Vote>() { new Vote { CommentId = "1111", VoteType = VoteType.UpVote }, new Vote { CommentId = "1111", VoteType = VoteType.UpVote }, new Vote { CommentId = "1111", VoteType = VoteType.UpVote }, new Vote { CommentId = "1111", VoteType = VoteType.DownVote }, }.AsQueryable()); var service = new VotesService(repository.Object); var votes = service.GetVotesCount("Comment", "1111"); Assert.Equal(3, votes.UpVotes); Assert.Equal(1, votes.DownVotes); }