示例#1
0
		public void Debug_WithoutCategoryAdded()
		{
			// arrange
			var logger = new Logger();
			var logs = new StringBuilder();
			logger.SetWriter(new StringWriter(logs));

			// act
			logger.Debug("debug message");

			// assert
			Assert.Equal(string.Empty, logs.ToString());
		}
示例#2
0
		public void Error()
		{
			// arrange
			var logger = new Logger();
			var logs = new StringBuilder();
			logger.SetWriter(new StringWriter(logs));
			logger.AddCategory("error");

			// act
			logger.Debug("debug message");
			logger.Info("info message");
			logger.Error("error message");

			// assert
			Assert.Equal("error message", logs.ToString().Trim());
		}
 private Logger GetLogger()
 {
     _loggerOutput = new StringBuilder();
     var writer = new StringWriter(_loggerOutput);
     var logger = new Logger();
     logger.SetWriter(writer);
     logger.AddCategory("info");
     logger.AddCategory("error");
     return logger;
 }