public void GetAllNotificationTemplates_Service_Fail() { // Arrange notificationTemplateService = new NotificationTemplateService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object); mockRepository.Setup(x => x.All <NotificationTemplate>()).Throws(new Exception()).Verifiable(); // Act var response = notificationTemplateService.GetAllNotificationTemplates(); // Assert Assert.IsNotNull(response); Assert.IsNull(response.Result); Assert.IsTrue(response.Notifications.HasErrors()); Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <IEnumerable <NotificationTemplateDto> >)); mockRepository.Verify(x => x.All <NotificationTemplate>(), Times.Once); }