コード例 #1
0
        public void AddMessage_WithErrorMessageTypeAndNullMessage_ShouldThrownLoggerDatabaseException()
        {
            // Arrange
            ILogger databaseLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.Database);

            // Act
            databaseLogger.AddMessage(MessageTypes.Error, null);

            // Assert
            // Expected LoggerDatabaseException
        }
コード例 #2
0
        public void AddMessage_WithWarningMessageTypeAndSomeMessage_ShouldAddLog()
        {
            // Arrange
            ILogger fileLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.File);

            // Act
            fileLogger.AddMessage(MessageTypes.Warning, "Warning Message");

            // Assert
            Assert.IsTrue(true);
        }
コード例 #3
0
        public void AddMessage_WithWarningMessageTypeAndEmptyMessage_ShouldThrownLoggerDatabaseException()
        {
            // Arrange
            ILogger databaseLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.Database);

            // Act
            databaseLogger.AddMessage(MessageTypes.Warning, "");

            // Assert
            // Expected LoggerDatabaseException
        }
コード例 #4
0
        public void AddMessage_WithWarningMessageTypeAndNullMessage_ShouldThrownLoggerFileException()
        {
            // Arrange
            ILogger fileLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.File);

            // Act
            fileLogger.AddMessage(MessageTypes.Warning, null);

            // Assert
            // Expected LoggerFileException
        }
コード例 #5
0
        public void AddMessage_WithInformationMessageTypeAndEmptyMessage_ShouldThrownLoggerFileException()
        {
            // Arrange
            ILogger fileLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.File);

            // Act
            fileLogger.AddMessage(MessageTypes.Information, "");

            // Assert
            // Expected LoggerFileException
        }
コード例 #6
0
        public void AddMessage_WithErrorMessageTypeAndEmptyMessage_ShouldThrownLoggerConsoleException()
        {
            // Arrange
            ILogger consoleLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.Console);

            // Act
            consoleLogger.AddMessage(MessageTypes.Error, "");

            // Assert
            // Expected LoggerConsoleException
        }
コード例 #7
0
        public void AddMessage_WithInformationMessageTypeAndSomeMessage_ShouldAddLog()
        {
            // Arrange
            ILogger consoleLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.Console);

            // Act
            consoleLogger.AddMessage(MessageTypes.Information, "Information Message");

            // Assert
            Assert.IsTrue(true);
        }
コード例 #8
0
        public void AddMessage_WithInformationMessageTypeAndNullMessage_ShouldThrownLoggerConsoleException()
        {
            // Arrange
            ILogger consoleLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.Console);

            // Act
            consoleLogger.AddMessage(MessageTypes.Information, null);

            // Assert
            // Expected LoggerConsoleException
        }
コード例 #9
0
        public static void Main(string[] args)
        {
            try
            {
                ILogger consoleLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.Console);
                consoleLogger.AddMessage(MessageTypes.Information, "Message Information");
                consoleLogger.AddMessage(MessageTypes.Warning, "Message Warning");
                consoleLogger.AddMessage(MessageTypes.Error, "Message Error");
            }
            catch (LoggerConsoleException ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                ILogger fileLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.File);
                fileLogger.AddMessage(MessageTypes.Information, "Message Information");
                fileLogger.AddMessage(MessageTypes.Warning, "Message Warning");
                fileLogger.AddMessage(MessageTypes.Error, "Message Error");
            }
            catch (LoggerFileException ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                ILogger databaseLogger = LoggerFactory.InitializeFactory().CreateLogger(LoggerTypes.Database);
                databaseLogger.AddMessage(MessageTypes.Information, "Message Information");
                databaseLogger.AddMessage(MessageTypes.Warning, "Message Warning");
                databaseLogger.AddMessage(MessageTypes.Error, "Message Error");
            }
            catch (LoggerDatabaseException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
コード例 #10
0
ファイル: LogWriter.cs プロジェクト: minskowl/Core.Libs
 /// <summary>
 /// Writes a string to the text stream.
 /// </summary>
 /// <param name="value">The string to write.</param>
 /// <exception cref="T:System.ObjectDisposedException">
 /// The <see cref="T:System.IO.TextWriter"/> is closed.
 /// </exception>
 /// <exception cref="T:System.IO.IOException">
 /// An I/O error occurs.
 /// </exception>
 public override void Write(string value)
 {
     _logger.AddMessage(_severity, value);
 }