public async Task GetCountShouldReturnTheCorrectCount() { this.Setup(); var repo = new Mock <IDeletableEntityRepository <ForumPost> >(); repo.Setup(x => x.All()).Returns(this.postsList.AsQueryable()); repo.Setup(x => x.AddAsync(It.IsAny <ForumPost>())).Callback( (ForumPost post) => this.postsList.Add(post)); var categoryRepo = new Mock <IDeletableEntityRepository <ForumCategory> >(); var postsService = new PostsService(repo.Object, categoryRepo.Object); await postsService.CreateAsync(this.testPost, "testUser"); var count = postsService.GetCount(); Assert.Equal(1, count); await postsService.CreateAsync(this.testPost, "testUser"); count = postsService.GetCount(); Assert.Equal(2, count); }