Пример #1
0
        public void WriteLine_Shoud_Log_To_Stream_The_Expected_Message()
        {
            string message = LoggerProvider.CreateLogMessage(MessageLength.Small);

            using (var stream = new MemoryStream())
            {
                _streamWriter.Writeline(stream, message);
                Assert.AreEqual(message, LoggerProvider.GetStreamContent(stream));
            }
        }
Пример #2
0
        public async Task Async_WriteLine_Shoud_Log_To_Stream_The_Expected_Message()
        {
            string message = LoggerProvider.CreateLogMessage(MessageLength.Small);

            using (var stream = new MemoryStream())
            {
                await _streamWriter.WriteLineAsync(stream, message).ConfigureAwait(false);

                Assert.AreEqual(message, LoggerProvider.GetStreamContent(stream));
            }
        }
Пример #3
0
 private static void StreamLoggerTest(LoggerFactory loggerFactory)
 {
     using (var stream = new StreamFactory().Create())
     {
         var logger = loggerFactory.CreateStreamLogger(stream, new StreamWriter());
         logger.Log(LogLevel.Debug, LoggerProvider.CreateLogMessage(MessageLength.Normal));
         logger.Log(LogLevel.Info, LoggerProvider.CreateLogMessage(MessageLength.Normal));
         logger.Log(LogLevel.Error, LoggerProvider.CreateLogMessage(MessageLength.Normal));
         var content = $"From Stream: {LoggerProvider.GetStreamContent(stream)}";
         System.Console.WriteLine(content);
     }
 }