Пример #1
0
        public void DefaultConstructorShouldLogAllKindOfMessages()
        {
            var logger = new FileLogger(fileHelper.FileDirectory);

            logger.LogMessage("Error Message", LogMessageType.Error);
            logger.LogMessage("Warning Message", LogMessageType.Warning);
            logger.LogMessage("Info Message", LogMessageType.Message);

            var logFile = fileHelper.GetLogFileContent();

            Assert.IsTrue(logFile.Contains("Error Message"));
            Assert.IsTrue(logFile.Contains("Warning Message"));
            Assert.IsTrue(logFile.Contains("Info Message"));
        }
Пример #2
0
        public void WithConsoleShouldOnlyLogToTheConsole()
        {
            var console = new ConsoleLogger();
            var logger  = new ComposedLogger(console);

            logger.LogMessage("This is a test message", LogMessageType.Message);

            var consoleContent = ConsoleHelper.ReadOutput();
            var dbRecords      = dbHelper.GetLogContent();
            var fileContent    = fileHelper.GetLogFileContent();

            Assert.IsTrue(consoleContent.Any());
            Assert.IsFalse(dbRecords.Any());
            Assert.IsFalse(fileContent.Any());
        }