Esempio n. 1
0
        public IActionResult Index()
        {
            ElmahExtensions.RaiseError(new InvalidOperationException("This is the Test Exception from code."));

            _logger.LogTrace("Test");
            _logger.LogDebug("Test");
            _logger.LogError("Test");
            _logger.LogInformation("Test");
            _logger.LogWarning("Test");
            _logger.LogCritical(new InvalidOperationException("Test"), "Test");

            ElmahExtensions.RaiseError(new NullReferenceException());

            if (DateTime.Now.Millisecond < 500)
            {
                string str = null;
                // ReSharper disable once PossibleNullReferenceException
                foreach (var cc in str)
                {
                    Debug.WriteLine(cc);
                }
            }

            var r = 0;
            // ReSharper disable once UnusedVariable
            // ReSharper disable once IntDivisionByZero
            var d = 100 / r;

            return(View());
        }
Esempio n. 2
0
        public void RiseErrorExceptionWhenMiddlewareNotInitialised()
        {
            var         httpContext = new DefaultHttpContext();
            Func <Task> act         = async() => await ElmahExtensions.RaiseError(httpContext, new Exception());

            act.Should().ThrowAsync <MiddlewareNotInitializedException>();
        }
Esempio n. 3
0
        public void RiseErrorOkWhenMiddlewareInitialized()
        {
            var         _           = new ErrorLogMiddleware(_requestDelegate, _errorLog, _loggerFactory, _options);
            var         httpContext = new DefaultHttpContext();
            Func <Task> act         = async() => await ElmahExtensions.RaiseError(httpContext, new Exception());

            act.Should().NotThrowAsync();
        }
Esempio n. 4
0
        public void OnGet()
        {
            _logger.LogTrace("Test");
            _logger.LogDebug("Test");
            _logger.LogError("Test");
            _logger.LogInformation("Test");
            _logger.LogWarning("Test");
            _logger.LogCritical(new InvalidOperationException("Test"), "Test");

            ElmahExtensions.RaiseError(new Exception("test2"));

            var r = 0;
            // ReSharper disable once UnusedVariable
            // ReSharper disable once IntDivisionByZero
            var d = 100 / r;
        }
Esempio n. 5
0
        public IActionResult Index()
        {
            //TestMethod("test", 100);


            _logger.LogTrace("Test");
            _logger.LogDebug("Test");
            _logger.LogError("Test");
            _logger.LogInformation("Test");
            _logger.LogWarning("Test");
            _logger.LogCritical(new InvalidOperationException("Test"), "Test");

            ElmahExtensions.RaiseError(new Exception("test2"));

            var r = 0;
            // ReSharper disable once UnusedVariable
            // ReSharper disable once IntDivisionByZero
            var d = 100 / r;

            return(View());
        }