< Summary - Combined Code Coverage

Information
Class: NLightning.Tests.Utils.Mocks.FakeServiceProvider
Assembly: NLightning.Tests.Utils
File(s): /home/runner/work/nlightning/nlightning/test/NLightning.Tests.Utils/Mocks/FakeServiceProvider.cs
Tag: 39_18410846617
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 23
Line coverage: 100%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
GetService(...)50%22100%
AddService(...)50%22100%

File(s)

/home/runner/work/nlightning/nlightning/test/NLightning.Tests.Utils/Mocks/FakeServiceProvider.cs

#LineLine coverage
 1using Microsoft.Extensions.DependencyInjection;
 2
 3namespace NLightning.Tests.Utils.Mocks;
 4
 5public class FakeServiceProvider : IServiceProvider
 6{
 967    private readonly Dictionary<Type, object> _services = [];
 8
 969    public FakeServiceProvider()
 10    {
 9611        _services.Add(typeof(IServiceScopeFactory), new FakeServiceScopeFactory(this));
 9612    }
 13
 14    public object? GetService(Type serviceType)
 15    {
 12816        return _services[serviceType] ?? throw new Exception("You should add the service first.");
 17    }
 18
 19    public void AddService<T>(T serviceType, object service)
 20    {
 9621        _services.Add(serviceType as Type ?? throw new Exception("Send Interface for type"), service);
 9622    }
 23}