< Summary

Information
Class: Chronicis.Client.Services.QuestDrawerService
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/QuestDrawerService.cs
Line coverage
100%
Covered lines: 35
Uncovered lines: 0
Coverable lines: 35
Total lines: 85
Line coverage: 100%
Branch coverage
100%
Covered branches: 20
Total branches: 20
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IsOpen()100%11100%
.ctor(...)100%11100%
Open()100%22100%
Close()100%44100%
Toggle()100%22100%
OnDrawerCoordinatorChanged()100%1010100%
Dispose()100%22100%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/QuestDrawerService.cs

#LineLine coverage
 1namespace Chronicis.Client.Services;
 2
 3/// <summary>
 4/// Service for coordinating quest drawer toggle events.
 5/// Wraps the shared drawer coordinator and preserves the existing event-based API.
 6/// </summary>
 7public class QuestDrawerService : IQuestDrawerService, IDisposable
 8{
 9    private readonly IDrawerCoordinator _drawerCoordinator;
 10    private bool _isOpen;
 11    private bool _disposed;
 12
 13    public event Action? OnOpen;
 14    public event Action? OnClose;
 15
 1316    public bool IsOpen => _isOpen;
 17
 18    public QuestDrawerService(IDrawerCoordinator drawerCoordinator)
 19    {
 1820        _drawerCoordinator = drawerCoordinator;
 1821        _isOpen = _drawerCoordinator.Current == DrawerType.Quests;
 1822        _drawerCoordinator.OnChanged += OnDrawerCoordinatorChanged;
 1823    }
 24
 25    public void Open()
 26    {
 1127        if (_disposed)
 228            return;
 29
 930        _drawerCoordinator.Open(DrawerType.Quests);
 931    }
 32
 33    public void Close()
 34    {
 435        if (_disposed || !_isOpen)
 336            return;
 37
 138        _drawerCoordinator.Close();
 139    }
 40
 41    public void Toggle()
 42    {
 643        if (_disposed)
 144            return;
 45
 546        _drawerCoordinator.Toggle(DrawerType.Quests);
 547    }
 48
 49    private void OnDrawerCoordinatorChanged()
 50    {
 1851        if (_disposed)
 52        {
 153            return;
 54        }
 55
 1756        var isOpenNow = _drawerCoordinator.Current == DrawerType.Quests;
 1757        if (_isOpen == isOpenNow)
 58        {
 159            return;
 60        }
 61
 1662        _isOpen = isOpenNow;
 1663        if (_isOpen)
 64        {
 1165            OnOpen?.Invoke();
 66        }
 67        else
 68        {
 569            OnClose?.Invoke();
 70        }
 271    }
 72
 73    public void Dispose()
 74    {
 2775        if (_disposed)
 976            return;
 77
 1878        _disposed = true;
 1879        _drawerCoordinator.OnChanged -= OnDrawerCoordinatorChanged;
 1880        OnOpen = null;
 1881        OnClose = null;
 82
 1883        GC.SuppressFinalize(this);
 1884    }
 85}