public void CommandExecutes() { bool executed = false; var target = new RelayCommand(() => executed = true); target.Execute(null); Assert.IsTrue(executed); }
public Notifications() { DefaultStyleKey = typeof(Notifications); CloseCommand = new RelayCommand<object>(CloseItem); NextCommand = new RelayCommand(MoveNext, CanMoveNext); PreviousCommand = new RelayCommand(MovePrevious, CanMovePrevious); }
public void ReceiveCorrectParameter() { bool canExecuteGotParam = false; bool executeGotParam = false; string paramValue = "whatever"; var target = new RelayCommand<string>( (param) => executeGotParam = (param == paramValue), (param) => canExecuteGotParam = (param == paramValue)); target.CanExecute(paramValue); target.Execute(paramValue); Assert.IsTrue(canExecuteGotParam); Assert.IsTrue(executeGotParam); }
public void CanExecuteReturnsFalse() { var target = new RelayCommand(Console.WriteLine, () => false); bool result = target.CanExecute(null); Assert.IsFalse(result); }