< Summary

Information
Class: Pomodoro.Web.Services.SessionOptionsService
Assembly: Pomodoro.Web
File(s): /home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Services/SessionOptionsService.cs
Line coverage
100%
Covered lines: 36
Uncovered lines: 0
Coverable lines: 36
Total lines: 70
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetOptionsForSessionType(...)100%44100%
GetDefaultOption(...)100%44100%

File(s)

/home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Services/SessionOptionsService.cs

#LineLine coverage
 1using Pomodoro.Web.Models;
 2
 3namespace Pomodoro.Web.Services;
 4
 5/// <summary>
 6/// Interface for session options generation
 7/// </summary>
 8public interface ISessionOptionsService
 9{
 10    /// <summary>
 11    /// Gets the available options for the completed session type
 12    /// </summary>
 13    List<ConsentOption> GetOptionsForSessionType(SessionType sessionType);
 14
 15    /// <summary>
 16    /// Gets the default option for the completed session type
 17    /// </summary>
 18    SessionType GetDefaultOption(SessionType completedSessionType);
 19}
 20
 21/// <summary>
 22/// Service for generating session options based on completed session type
 23/// Separated from ConsentService for better single responsibility
 24/// </summary>
 25public class SessionOptionsService : ISessionOptionsService
 26{
 27    private readonly AppState _appState;
 28
 2329    public SessionOptionsService(AppState appState)
 2330    {
 2331        _appState = appState;
 2332    }
 33
 34    public List<ConsentOption> GetOptionsForSessionType(SessionType sessionType)
 1935    {
 1936        var settings = _appState.Settings;
 37
 1938        return sessionType switch
 1939        {
 840            SessionType.Pomodoro => new List<ConsentOption>
 841            {
 842                new() { SessionType = SessionType.ShortBreak, Label = Constants.SessionOptionLabels.ShortBreak, Duration
 843                new() { SessionType = SessionType.LongBreak, Label = Constants.SessionOptionLabels.LongBreak, Duration =
 844                new() { SessionType = SessionType.Pomodoro, Label = Constants.SessionOptionLabels.AnotherPomodoro, Durat
 845            },
 546            SessionType.ShortBreak => new List<ConsentOption>
 547            {
 548                new() { SessionType = SessionType.Pomodoro, Label = Constants.SessionOptionLabels.StartPomodoro, Duratio
 549                new() { SessionType = SessionType.ShortBreak, Label = Constants.SessionOptionLabels.ShortBreak, Duration
 550            },
 551            SessionType.LongBreak => new List<ConsentOption>
 552            {
 553                new() { SessionType = SessionType.Pomodoro, Label = Constants.SessionOptionLabels.StartPomodoro, Duratio
 554                new() { SessionType = SessionType.LongBreak, Label = Constants.SessionOptionLabels.LongBreak, Duration =
 555            },
 156            _ => new List<ConsentOption>()
 1957        };
 1958    }
 59
 60    public SessionType GetDefaultOption(SessionType completedSessionType)
 461    {
 462        return completedSessionType switch
 463        {
 164            SessionType.Pomodoro => SessionType.Pomodoro, // Continue with another pomodoro
 165            SessionType.ShortBreak => SessionType.ShortBreak, // Continue short break
 166            SessionType.LongBreak => SessionType.LongBreak, // Continue long break
 167            _ => SessionType.Pomodoro
 468        };
 469    }
 70}