public void AddToLoggersTest() { var origOut = Console.Out; using (StringWriter sw = new StringWriter()) { //Log once, add the logger, then log again. //We should only see the second log event. Console.SetOut(sw); LoggerFactory.CreateLoggers(LogLevelEnum.Debug, new Type[] { }); LoggerFactory.Log("LoggerFactoryTest", LogLevelEnum.Debug, "This is a {0}.", "test"); LoggerFactory.AddToLoggers(typeof(ConsoleLogger)); LoggerFactory.Log("LoggerFactoryTest", LogLevelEnum.Debug, "This is a {0}.", "test"); String expected = String.Format("[Debug] LoggerFactoryTest:This is a test. {0}", Environment.NewLine); Assert.AreEqual <string>(expected, sw.ToString()); } Console.SetOut(origOut); }
public void GetLoggerByTypeTest() { LoggerFactory.AddToLoggers(typeof(ConsoleLogger)); Assert.IsInstanceOfType(LoggerFactory.GetLoggerByType <ConsoleLogger>(), typeof(ConsoleLogger)); }