< Summary

Information
Class: OffRouteMap.RelayCommand
Assembly: OffRouteMap
File(s): D:\a\OffRouteMap\OffRouteMap\RelayCommand.cs
Tag: 5_18712131505
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 30
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
add_CanExecuteChanged(...)100%210%
remove_CanExecuteChanged(...)100%210%
CanExecute(...)0%620%
Execute(...)100%210%

File(s)

D:\a\OffRouteMap\OffRouteMap\RelayCommand.cs

#LineLine coverage
 1using System;
 2using System.Windows.Input;
 3
 4namespace OffRouteMap
 5{
 6    /// <summary>
 7    /// A Helper class to bind UI Events to simple Map methods.
 8    /// </summary>
 9    public class RelayCommand : ICommand
 10    {
 11        private readonly Action _execute;
 12        private readonly Func<bool> _canExecute;
 13
 014        public RelayCommand (Action execute, Func<bool> canExecute = null)
 15        {
 016            _execute = execute;
 017            _canExecute = canExecute;
 018        }
 19
 20        public event EventHandler CanExecuteChanged
 21        {
 022            add => CommandManager.RequerySuggested += value;
 023            remove => CommandManager.RequerySuggested -= value;
 24        }
 25
 026        public bool CanExecute (object parameter) => _canExecute == null || _canExecute();
 27
 028        public void Execute (object parameter) => _execute();
 29    }
 30}