public void GetReminderByIdShouldThrowException() { int Id = 2; Reminder reminder = null; var mockRepo = new Mock <IReminderRepository>(); mockRepo.Setup(repo => repo.GetReminderById(Id)).Returns(reminder); var service = new ReminderService(mockRepo.Object); var actual = Assert.Throws <ReminderNotFoundException>(() => service.GetReminderById(Id)); Assert.Equal($"Reminder with id: {Id} does not exist", actual.Message); }
public void GetReminderByIdShouldReturnAReminder() { int Id = 1; Reminder reminder = new Reminder { ReminderId = 1, ReminderName = "Email", ReminderDescription = "Email reminder", ReminderType = "notification", CreatedBy = "John" }; var mockRepo = new Mock <IReminderRepository>(); mockRepo.Setup(repo => repo.GetReminderById(Id)).Returns(reminder); var service = new ReminderService(mockRepo.Object); var actual = service.GetReminderById(Id); Assert.NotNull(actual); Assert.IsAssignableFrom <Reminder>(actual); }