< 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: 36_15743069263
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{
 807    private readonly Dictionary<Type, object> _services = [];
 8
 809    public FakeServiceProvider()
 10    {
 8011        _services.Add(typeof(IServiceScopeFactory), new FakeServiceScopeFactory(this));
 8012    }
 13
 14    public object? GetService(Type serviceType)
 15    {
 9616        return _services[serviceType] ?? throw new Exception("You should add the service first.");
 17    }
 18
 19    public void AddService<T>(T serviceType, object service)
 20    {
 8021        _services.Add(serviceType as Type ?? throw new Exception("Send Interface for type"), service);
 8022    }
 23}