< Summary - ZhEaIsNsAaBn.Essentials coverage

Information
Class: ZhEaIsNsAaBn.Utilities.ResourceErrorMessageSource
Assembly: ZhEaIsNsAaBn.LayerResponse
File(s): /_work/home-runner-1/ZhEaIsNsAaBn.Essentials/ZhEaIsNsAaBn.Essentials/src/Core/LayerResponse/Errors/ResourceErrorMessageSource.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 42
Line coverage: 0%
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%210%
Find(...)0%620%

File(s)

/_work/home-runner-1/ZhEaIsNsAaBn.Essentials/ZhEaIsNsAaBn.Essentials/src/Core/LayerResponse/Errors/ResourceErrorMessageSource.cs

#LineLine coverage
 1#region Usings
 2using System.Globalization;
 3using System.Resources;
 4#endregion
 5
 6namespace ZhEaIsNsAaBn.Utilities;
 7
 8/// <summary>
 9/// Reads error messages from <c>.resx</c> files: resource name = <see cref="Error.Code"/>. The neutral file (<c>Errors.
 10/// English; each language adds its own (<c>Errors.ar.resx</c>, <c>Errors.fr.resx</c>).
 11/// </summary>
 12/// <example>
 13/// <code>
 14/// var source = new ResourceErrorMessageSource( AppErrors.ResourceManager );   // AppErrors = the .resx designer class
 15/// </code>
 16/// </example>
 17public sealed class ResourceErrorMessageSource : IErrorMessageSource
 18{
 19    private readonly ResourceManager _resourceManager;
 20
 21
 22    /// <summary>Creates the source.</summary>
 23    /// <param name="resourceManager">The resources, e.g. the <c>ResourceManager</c> of a <c>.resx</c> designer class.</
 24    /// <exception cref="ArgumentNullException"><paramref name="resourceManager"/> is <see langword="null"/>.</exception
 025    public ResourceErrorMessageSource( ResourceManager resourceManager )
 26    {
 027        ArgumentNullException.ThrowIfNull( resourceManager );
 28
 029        _resourceManager = resourceManager;
 030    }
 31
 32
 33    /// <inheritdoc />
 34    /// <exception cref="ArgumentNullException"><paramref name="code"/> or <paramref name="culture"/> is <see langword="
 35    public string? Find( string code, CultureInfo culture )
 36    {
 037        ArgumentNullException.ThrowIfNull( code );
 038        ArgumentNullException.ThrowIfNull( culture );
 39
 040        return _resourceManager.GetResourceSet( culture, createIfNotExists: true, tryParents: false )?.GetString( code )
 41    }
 42}