public void WhenLoggingErrorShouldWriteErrorInConsole() { //Arrange IJobLogger jobLogger = new DatabaseJobLogger(this.mockOutputWriter.Object); //Act jobLogger.LogMessage(MessageFixture.CreateError()); //Assert mockOutputWriter.Verify(w => w.Save(It.IsAny <Message>()), Times.Once); }
public void Initialize() { this.mockJobLoggerFactory = new Mock <IJobLoggerFactory>(); this.mockOutputWriter = new Mock <IOutputWriter>(); this.mockDatabaseWriter = new Mock <IDataBaseWritter>(); this.mockFileWriter = new Mock <IFileWritter>(); this.mockJobLoggerFactory.Setup(jl => jl.Create(It.IsAny <Enum.EnumJobLoggerType>())) .Returns((Enum.EnumJobLoggerType type) => { IJobLogger jobLogger = (IJobLogger)null; switch (type) { case Enum.EnumJobLoggerType.CONSOLE: { jobLogger = new ConsoleJobLogger(mockOutputWriter.Object); break; } case Enum.EnumJobLoggerType.DATABASE: { jobLogger = new DatabaseJobLogger(mockDatabaseWriter.Object); break; } default: { jobLogger = new FileJobLogger(mockFileWriter.Object); break; } } return(jobLogger); }); this.messageFactory = new MessageFactory(); }