< Summary

Information
Class: Syki.Back.Settings.FeaturesSettings
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Settings/FeaturesSettings.cs
Tag: 22_11348620282
Line coverage
83%
Covered lines: 5
Uncovered lines: 1
Coverable lines: 6
Total lines: 39
Line coverage: 83.3%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_SkipUserRegister()100%11100%
get_CrossLogin()100%11100%
.ctor()100%210%
.ctor(...)100%11100%

File(s)

/home/runner/work/syki/syki/Back/Settings/FeaturesSettings.cs

#LineLine coverage
 1namespace Syki.Back.Settings;
 2
 3public class FeaturesSettings
 4{
 49585    public bool SkipUserRegister { get; set; }
 49646    public bool CrossLogin { get; set; }
 7
 08    public FeaturesSettings() {}
 9
 110    public FeaturesSettings(IConfiguration configuration)
 11    {
 112        configuration.GetSection("Features").Bind(this);
 113    }
 14}
 15
 16public class LoadFeatureFlagsFromDb(IServiceScopeFactory serviceScopeFactory, FeaturesSettings settings) : IHostedServic
 17{
 18    public async Task StartAsync(CancellationToken cancellationToken)
 19    {
 20        if (Env.IsTesting()) return;
 21
 22        using IServiceScope scope = serviceScopeFactory.CreateScope();
 23        var ctx = scope.ServiceProvider.GetRequiredService<SykiDbContext>();
 24
 25        var features = await ctx.FeatureFlags.AsNoTracking()
 26            .Where(f => f.Id == Guid.Empty)
 27            .FirstOrDefaultAsync(cancellationToken);
 28
 29        if (features == null) return;
 30
 31        settings.SkipUserRegister = features.Settings.SkipUserRegister;
 32        settings.CrossLogin = features.Settings.CrossLogin;
 33    }
 34
 35    public Task StopAsync(CancellationToken cancellationToken)
 36    {
 37        return Task.CompletedTask;
 38    }
 39}