< Summary - SonghayCore

Information
Class: Songhay.Models.ActivitiesGetter
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Models/ActivitiesGetter.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 55
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
get_Args()100%1100%
GetActivity()100%1100%
GetActivity(...)100%1100%
LoadActivities(...)100%1100%
ToActivityArgs(...)100%2100%
ToActivityName(...)100%1100%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Models/ActivitiesGetter.cs

#LineLine coverage
 1namespace Songhay.Models;
 2
 3/// <summary>
 4/// Defines the in-memory storage
 5/// and Program access to <see cref="IActivity"/> types.
 6/// </summary>
 7public abstract class ActivitiesGetter
 8{
 9    /// <summary>
 10    /// Initializes a new instance of the <see cref="ActivitiesGetter" /> class.
 11    /// </summary>
 12    /// <param name="args">The arguments.</param>
 713    public ActivitiesGetter(string[] args)
 714    {
 715        _defaultActivityName = ToActivityName(args);
 516        Args = new ProgramArgs(ToActivityArgs(args));
 517    }
 18
 19    /// <summary>
 20    /// Gets the <see cref="ProgramArgs"/>.
 21    /// </summary>
 422    public ProgramArgs Args { get; }
 23
 24    /// <summary>
 25    /// Gets the <see cref="IActivity"/>.
 26    /// </summary>
 427    public virtual IActivity? GetActivity() => _activities.GetActivity(_defaultActivityName);
 28
 29    /// <summary>
 30    /// Gets the <see cref="IActivity"/>.
 31    /// </summary>
 32    /// <param name="activityName">Name of the <see cref="IActivity"/>.</param>
 133    public virtual IActivity? GetActivity(string activityName) => _activities.GetActivity(activityName);
 34
 35    /// <summary>
 36    /// Loads the activities into memory, lazily.
 37    /// </summary>
 38    /// <param name="activities">The activities.</param>
 539    public virtual void LoadActivities(Dictionary<string, Lazy<IActivity?>>? activities) => _activities = activities;
 40
 41    static string[] ToActivityArgs(string[] args)
 542    {
 543        return args.Length < 2 ? Enumerable.Empty<string>().ToArray() : args.Skip(1).ToArray();
 544    }
 45
 46    static string ToActivityName(string[] args)
 747    {
 748        args.ThrowWhenNullOrEmpty();
 49
 550        return args.First();
 551    }
 52
 53    Dictionary<string, Lazy<IActivity?>>? _activities;
 54    readonly string _defaultActivityName;
 55}