< Summary - CoreWCF Coverage — PR #1766

Information
Class: Helpers.ExceptionCapturingLogger
Assembly: UnitTests.Common
File(s): /home/runner/work/CoreWCF/CoreWCF/src/Common/UnitTests.Common/Helpers/ExceptionCapturingLogger.cs
Line coverage
92%
Covered lines: 12
Uncovered lines: 1
Coverable lines: 13
Total lines: 40
Line coverage: 92.3%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
Log(...)75%44100%
IsEnabled(...)0%220%
BeginScope(...)100%11100%
.cctor()100%11100%
Dispose()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/Common/UnitTests.Common/Helpers/ExceptionCapturingLogger.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Collections.Concurrent;
 6using System.Collections.Generic;
 7using Microsoft.Extensions.Logging;
 8
 9namespace Helpers
 10{
 11    public class ExceptionCapturingLogger : ILogger
 12    {
 13        private readonly ILogger _wrappedLogger;
 224114        private readonly ConcurrentBag<Exception> _exceptionsLogged = new();
 224115        public ExceptionCapturingLogger(ILogger wrappedLogger)
 16        {
 224117            _wrappedLogger = wrappedLogger;
 224118        }
 19
 20        public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exce
 21        {
 7922            _wrappedLogger?.Log(logLevel, eventId, state, exception, formatter);
 7923            if (exception != null)
 24            {
 225                _exceptionsLogged.Add(exception);
 26            }
 7927        }
 28
 029        public bool IsEnabled(LogLevel logLevel) => _wrappedLogger?.IsEnabled(logLevel) ?? (int)logLevel>= (int)LogLevel
 30
 7931        public IDisposable BeginScope<TState>(TState state) => NoopDisposable.Instance;
 2932        public IEnumerable<Exception> ExceptionsLogged => _exceptionsLogged;
 33        private class NoopDisposable : IDisposable
 34        {
 135            public static NoopDisposable Instance = new NoopDisposable();
 36            public void Dispose()
 7937            { }
 38        }
 39    }
 40}