Beispiel #1
0
        public void LogsModuleNotFound(bool isException)
        {
            const string FakeUnknownModule = "UnknownModule";

            var error = CreateModuleNotFoundError(FakeUnknownModule);

            ErrorAnalysisLogger.Log(_mockLogger.Object, error, isException);

            _mockLogger.Verify(
                _ => _.Log(
                    false,
                    LogLevel.Warning,
                    It.Is <string>(
                        message => message.Contains("ModuleNotFound") &&
                        (isException && message.Contains("(exception)") && !message.Contains("(error)") ||
                         !isException && message.Contains("(error)") && !message.Contains("(exception)")) &&
                        !message.Contains(FakeUnknownModule)),
                    null),
                Times.Once);

            _mockLogger.Verify(
                _ => _.Log(
                    true,
                    LogLevel.Warning,
                    It.Is <string>(message => message.Contains(FakeUnknownModule)),
                    null),
                Times.Once);

            _mockLogger.VerifyNoOtherCalls();
        }
Beispiel #2
0
        public void DoesNotLogUnknownErrors(bool isException)
        {
            var error = new ErrorRecord(
                new Exception(),
                "UnknownException",
                ErrorCategory.NotSpecified,
                "Dummy target object");

            ErrorAnalysisLogger.Log(_mockLogger.Object, error, isException);
        }