< Summary

Information
Class: RoleRadar.Application.Insights.InsightsWindows
Assembly: RoleRadar.Application
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Application/Insights/InsightsWindow.cs
Line coverage
92%
Covered lines: 12
Uncovered lines: 1
Coverable lines: 13
Total lines: 40
Line coverage: 92.3%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Names()100%11100%
ToWireName(...)75%4483.33%
TryParse(...)100%22100%

File(s)

/home/runner/work/roleradar/roleradar/src/RoleRadar.Application/Insights/InsightsWindow.cs

#LineLine coverage
 1namespace RoleRadar.Application.Insights;
 2
 3/// <summary>The two windows the Insights page offers. The wire names are <see cref="InsightsWindows.Last90DaysName"/> a
 4public enum InsightsWindow
 5{
 6    Last90Days,
 7    AllTime
 8}
 9
 10/// <summary>Wire names for <see cref="InsightsWindow"/> (a string enum in the OpenAPI schema). Matching is exact and ca
 11public static class InsightsWindows
 12{
 13    public const string Last90DaysName = "last90Days";
 14    public const string AllTimeName = "allTime";
 15
 3216    public static IReadOnlyList<string> Names { get; } = [Last90DaysName, AllTimeName];
 17
 5618    public static string ToWireName(InsightsWindow window) => window switch
 5619    {
 3220        InsightsWindow.Last90Days => Last90DaysName,
 2421        InsightsWindow.AllTime => AllTimeName,
 022        _ => throw new ArgumentOutOfRangeException(nameof(window), window, "Unknown Insights window.")
 5623    };
 24
 25    public static bool TryParse(string? value, out InsightsWindow window)
 26    {
 27        switch (value)
 28        {
 29            case Last90DaysName:
 3830                window = InsightsWindow.Last90Days;
 3831                return true;
 32            case AllTimeName:
 2033                window = InsightsWindow.AllTime;
 2034                return true;
 35            default:
 2036                window = default;
 2037                return false;
 38        }
 39    }
 40}