< Summary - Syki

Information
Class: Syki.Back.Configs.ServicesConfigs
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Configs/ServicesConfigs.cs
Tag: 97_27801654829
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddServicesConfigs(...)100%22100%
AddServices(...)100%44100%

File(s)

/home/runner/work/syki/syki/Back/Configs/ServicesConfigs.cs

#LineLine coverage
 1using Syki.Back.Emails;
 2using Syki.Back.Google;
 3using Syki.Back.Storage;
 4using Microsoft.Extensions.DependencyInjection.Extensions;
 5
 6namespace Syki.Back.Configs;
 7
 8public static class ServicesConfigs
 9{
 10    public static void AddServicesConfigs(this WebApplicationBuilder builder)
 11    {
 212        builder.Services.AddServices(typeof(ISykiService));
 13
 214        builder.Services.AddScoped<IEmailsService, EmailsService>();
 215        builder.Services.AddScoped<IGoogleService, GoogleService>();
 216        builder.Services.AddScoped<IStorageService, FakeStorageService>();
 17
 218        if (EnvironmentExtensions.IsTesting())
 19        {
 220            builder.Services.Replace(ServiceDescriptor.Singleton<IGoogleService, FakeGoogleService>());
 221            builder.Services.Replace(ServiceDescriptor.Singleton<IEmailsService, FakeEmailsService>());
 22        }
 223    }
 24
 25    private static void AddServices(this IServiceCollection services, Type marker)
 26    {
 227        var types = AppDomain.CurrentDomain.GetAssemblies()
 30628            .Where(s => s.FullName.StartsWith("Back"))
 229            .SelectMany(s => s.GetTypes())
 289230            .Where(p => marker.IsAssignableFrom(p) && !p.IsInterface)
 231            .ToList();
 32
 28433        foreach (var type in types)
 34        {
 14035            services.AddScoped(type);
 36        }
 237    }
 38}