< Summary

Information
Class: MyNet.UI.ViewModels.ShellDrawerActionExtensions
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/ViewModels/Extensions/ShellDrawerActionExtensions.cs
Tag: 323_28699572109
Line coverage
71%
Covered lines: 10
Uncovered lines: 4
Coverable lines: 14
Total lines: 45
Line coverage: 71.4%
Branch coverage
50%
Covered branches: 4
Total branches: 8
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
WillOpen(...)50%4471.42%
ApplyToOpenState(...)50%4471.42%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/ViewModels/Extensions/ShellDrawerActionExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="ShellDrawerActionExtensions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using MyNet.UI.ViewModels.Shell;
 8
 9#pragma warning disable IDE0130
 10namespace MyNet.UI.ViewModels;
 11#pragma warning restore IDE0130
 12
 13/// <summary>
 14/// Helpers for <see cref="ShellDrawerAction"/>.
 15/// </summary>
 16public static class ShellDrawerActionExtensions
 17{
 18    extension(ShellDrawerAction action)
 19    {
 20        /// <summary>
 21        /// Returns whether the action opens the drawer from the given state.
 22        /// </summary>
 23        public bool WillOpen(bool isOpen)
 1224            => action switch
 1225            {
 626                ShellDrawerAction.Show => true,
 027                ShellDrawerAction.Hide => false,
 628                ShellDrawerAction.Toggle => !isOpen,
 029                _ => false
 1230            };
 31
 32        /// <summary>
 33        /// Applies a drawer visibility action to the current open state.
 34        /// </summary>
 35        public bool ApplyToOpenState(bool isOpen)
 1236            => action switch
 1237            {
 638                ShellDrawerAction.Show => true,
 039                ShellDrawerAction.Hide => false,
 640                ShellDrawerAction.Toggle => !isOpen,
 041                _ => isOpen
 1242            };
 43    }
 44}
 45