public void DeleteTaskTest() { var testGuid = Guid.NewGuid(); var request = new DeleteTaskRequest(testGuid); var expectedResonse = new DeleteTaskResponse { Exception = null }; var mockService = new Mock <ITaskService>(); mockService.Setup(x => x.DeleteTask(request)).Returns(expectedResonse); var mockLogger = new Mock <ILoggingService>(); var mockEmail = new Mock <IEmailService>(); var mockConfig = new Mock <IAppConfig <IServiceConfigOptions> >(); var service = new EnrichedTaskService(mockService.Object, mockLogger.Object, mockEmail.Object, mockConfig.Object); var response = service.DeleteTask(request); Assert.IsNull(response.Exception); Assert.AreEqual(expectedResonse.Exception, response.Exception); mockService.Verify(x => x.DeleteTask(request), Times.Once); }
public void DeleteTaskInvalidTest() { var testGuid = Guid.NewGuid(); var request = new DeleteTaskRequest(testGuid); var expectedResonse = new DeleteTaskResponse { Exception = new ValidationException("invalid") }; var mockService = new Mock <ITaskService>(); mockService.Setup(x => x.DeleteTask(request)).Returns(expectedResonse); var mockLogger = new Mock <ILoggingService>(); var mockEmail = new Mock <IEmailService>(); var mockConfigOptions = new Mock <IServiceConfigOptions>(); mockConfigOptions.Setup(x => x.AdminEmail).Returns("test"); mockConfigOptions.Setup(x => x.ErrorEmailSubject).Returns("test"); mockConfigOptions.Setup(x => x.SmtpServer).Returns("test"); mockConfigOptions.Setup(x => x.SystemEmail).Returns("test"); var mockConfig = new Mock <IAppConfig <IServiceConfigOptions> >(); mockConfig.Setup(x => x.Options).Returns(mockConfigOptions.Object); var service = new EnrichedTaskService(mockService.Object, mockLogger.Object, mockEmail.Object, mockConfig.Object); var response = service.DeleteTask(request); Assert.IsNotNull(response.Exception); mockLogger.Verify(x => x.LogError(It.IsAny <object>(), "invalid", It.IsAny <ValidationException>()), Times.Once); mockEmail.Verify(x => x.SendEmail(It.IsAny <EmailArguments>()), Times.Once); }