public async Task DeleteReminderShouldThrowException() { string userId = "Sam"; int newsId = 101; var mockRepo = new Mock <INewsRepository>(); mockRepo.Setup(repo => repo.IsReminderExists(userId, newsId)).Returns(Task.FromResult(false)); var service = new NewsService.Services.NewsService(mockRepo.Object); var actual = await Assert.ThrowsAsync <NoReminderFoundException>(() => service.DeleteReminder(userId, newsId)); Assert.Equal("No reminder found for this news", actual.Message); }
public async Task DeleteReminderShouldSuccess() { string userId = "Sam"; int newsId = 101; var mockRepo = new Mock <INewsRepository>(); mockRepo.Setup(repo => repo.IsReminderExists(userId, newsId)).Returns(Task.FromResult(true)); mockRepo.Setup(repo => repo.DeleteReminder(userId, newsId)).Returns(Task.FromResult(true)); var service = new NewsService.Services.NewsService(mockRepo.Object); var actual = await service.DeleteReminder(userId, newsId); Assert.True(actual); }