Ejemplo n.º 1
0
        public void TestSimpleLayout_ShouldBeInCorrectFormat()
        {
            // Arrange
            ILayout layout = new SimpleLayout();
            DateTime date = It.IsAny<DateTime>();
            const ReportLevel ReportLevel = ReportLevel.Error;
            const string Message = "Exo";
            string expectedOutput = string.Format("{0}-{1}-{2}", date, ReportLevel, Message);

            // Act
            var actualOutput = layout.LayoutMaker(date, ReportLevel, Message);

            // Assert
            Assert.AreEqual(expectedOutput, actualOutput);
        }
Ejemplo n.º 2
0
 public void TestLoggerWarning_ShouldAppendOnTheConsoleCorrectly()
 {
     DateTime date = DateTime.Now;
     const ReportLevel ReportLevel = ReportLevel.Warnimg;
     var message = It.IsAny<string>();
     string expetedOutput = string.Format("{0}-{1}-{2}{3}", date, ReportLevel, message, Environment.NewLine);
     var layout = new SimpleLayout();
     IAppender consoleAppender = new ConsoleAppender(layout);
     ILogger logger = new Logger(consoleAppender);
     StringWriter actualOutput = new StringWriter();
     Console.SetOut(actualOutput);
     logger.Warning(message);
     Assert.AreEqual(expetedOutput, actualOutput.ToString());
 }