public async Task DeletePhotoCommentShouldNotDelete() { var comments = new List <Comment>(); var appUsers = new List <ApplicationUser>(); 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 mockAppUser = new Mock <IDeletableEntityRepository <ApplicationUser> >(); mockAppUser.Setup(x => x.All()).Returns(appUsers.AsQueryable()); mockAppUser.Setup(x => x.AddAsync(It.IsAny <ApplicationUser>())).Callback((ApplicationUser appU) => appUsers.Add(appU)); var service = new CommentsService(mockCommentRepo.Object, null, mockAppUser.Object); var commentToDelete = new Comment { Id = "1", UserId = "1", SentById = "1", }; comments.Add(commentToDelete); Task result = service.DeletePhotoCommentAsync("2", "1"); Assert.True(!result.IsCompletedSuccessfully); }