< Summary

Information
Class: Syki.Back.Settings.LoadFeatureFlagsFromDb
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Settings/FeaturesSettings.cs
Tag: 22_11348620282
Line coverage
33%
Covered lines: 4
Uncovered lines: 8
Coverable lines: 12
Total lines: 39
Line coverage: 33.3%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
StartAsync()0%4.05220%
StopAsync(...)100%11100%

File(s)

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

#LineLine coverage
 1namespace Syki.Back.Settings;
 2
 3public class FeaturesSettings
 4{
 5    public bool SkipUserRegister { get; set; }
 6    public bool CrossLogin { get; set; }
 7
 8    public FeaturesSettings() {}
 9
 10    public FeaturesSettings(IConfiguration configuration)
 11    {
 12        configuration.GetSection("Features").Bind(this);
 13    }
 14}
 15
 116public class LoadFeatureFlagsFromDb(IServiceScopeFactory serviceScopeFactory, FeaturesSettings settings) : IHostedServic
 17{
 18    public async Task StartAsync(CancellationToken cancellationToken)
 19    {
 220        if (Env.IsTesting()) return;
 21
 022        using IServiceScope scope = serviceScopeFactory.CreateScope();
 023        var ctx = scope.ServiceProvider.GetRequiredService<SykiDbContext>();
 24
 025        var features = await ctx.FeatureFlags.AsNoTracking()
 026            .Where(f => f.Id == Guid.Empty)
 027            .FirstOrDefaultAsync(cancellationToken);
 28
 029        if (features == null) return;
 30
 031        settings.SkipUserRegister = features.Settings.SkipUserRegister;
 032        settings.CrossLogin = features.Settings.CrossLogin;
 133    }
 34
 35    public Task StopAsync(CancellationToken cancellationToken)
 36    {
 137        return Task.CompletedTask;
 38    }
 39}