< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Class: ZhEaIsNsAaBn.DbSeeder.Design.SeedProfileStore
Assembly: ZhEaIsNsAaBn.DbSeeder.Design
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder.Design/Profiles/SeedProfileStore.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 38
Line coverage: 100%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor(...)100%11100%
Load()66.66%66100%
Save(...)100%11100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder.Design/Profiles/SeedProfileStore.cs

#LineLine coverage
 1#region Usings
 2using System.Text.Encodings.Web;
 3using System.Text.Unicode;
 4#endregion
 5
 6namespace ZhEaIsNsAaBn.DbSeeder.Design;
 7
 8/// <c>.dbseeder/profiles.json</c> under the project folder (deterministic, CRLF).
 9internal sealed class SeedProfileStore
 10{
 311    private static readonly JsonSerializerOptions Options = new() { WriteIndented = true, Encoder = JavaScriptEncoder.Cr
 12
 13    private readonly string _path;
 14
 15
 82216    public SeedProfileStore( string root ) => _path = Path.Combine( root, ".dbseeder", "profiles.json" );
 17
 18
 19    public List<SeedProfile> Load()
 41120        => File.Exists( _path )
 41121               ? JsonSerializer.Deserialize<ProfilesFile>( File.ReadAllText( _path ), Options )?.Profiles.ToList() ?? []
 41122               : [];
 23
 24    public void Save( IEnumerable<SeedProfile> profiles )
 25    {
 8426        Directory.CreateDirectory( Path.GetDirectoryName( _path )! );
 27
 8428        var file = new ProfilesFile { Profiles = profiles.OrderBy( p => p.Name, StringComparer.Ordinal ).ToList() };
 29
 8430        File.WriteAllText( _path, SeedFileWriter.Normalize( JsonSerializer.Serialize( file, Options ) ), new UTF8Encodin
 8431    }
 32
 33
 34    private sealed class ProfilesFile
 35    {
 36        public IReadOnlyList<SeedProfile> Profiles { get; init; } = [];
 37    }
 38}