public void Log_WithNullException_ThrowsException()
        {
            // Arrange
            _exception = null;

            // Act
            _exception.Log(_mockLog.Object, LogLevel.Error);
        }
        public void Log_WithoutNestedException_LogsOnlyException()
        {
            // Arrange
            _exception = new SystemException(_exceptionMessage);

            // Act
            _exception.Log(_mockLog.Object, _level);

            var loggedItems = _mockLog.LoggedItems;
            var logItem     = loggedItems.FirstOrDefault();

            // Assert
            Assert.IsTrue(logItem.Message.TrimEnd() == _exceptionMessage, "The two messages should be identical after the stringbuilder \r\n sequences are removed.");
        }
        public void Log_WithMultipleNestedExceptions_LogsAll()
        {
            // Arrange
            var _innerInnerExceptionMessage = "InnerInnerExceptionMessage: Test ArgumentNullException Message.";

            _innerException = new InvalidOperationException(_innerExceptionMessage, new ArgumentNullException("TestArgumentException", _innerInnerExceptionMessage));
            _exception      = new SystemException(_exceptionMessage, _innerException);

            // Act
            _exception.Log(_mockLog.Object, _level);

            var loggedItems = _mockLog.LoggedItems;
            var logItem     = loggedItems.FirstOrDefault();

            // Assert
            Assert.IsTrue(logItem.Message.Contains(_exceptionMessage));
            Assert.IsTrue(logItem.Message.Contains(_innerExceptionMessage));
            Assert.IsTrue(logItem.Message.Contains(_innerInnerExceptionMessage));
        }
 public void Log_WithNullLog_ThrowsException()
 {
     // Act
     _exception.Log(null, _level);
 }