public void TestRelayCommandWithNullValueTypeParam() { RelayCommand<int> command = new RelayCommand<int>( e => Assert.That(e, Is.EqualTo(0)), i => { Assert.That(i, Is.EqualTo(0)); return true; }); Assert.That(command.HasCanExecuteFunction, Is.True); Assert.That(command.CanExecute(null), Is.True); command.Execute(null); Assert.That(command.CanExecute(null), Is.True); }
public void TestRelayCommandWithParamNoCanExecute() { const string parameterString = "567"; int parameterAsInt = int.Parse(parameterString); bool actionPerformed = false; string executeActionParam = string.Empty; RelayCommand<string> command = new RelayCommand<string>( e => { executeActionParam = e; actionPerformed = true; }); Assert.That(command.HasCanExecuteFunction, Is.False); Assert.That(command.CanExecute(parameterString), Is.True); command.Execute(parameterAsInt); Assert.That(command.CanExecute(parameterString), Is.True); // Check convertible parameter. Assert.That(command.CanExecute(parameterAsInt), Is.True); Assert.That(actionPerformed, Is.True); Assert.That(executeActionParam, Is.EqualTo(parameterString)); }
public void TestRelayCommandNoParamNoCanExecute() { bool actionPerformed = false; BaseCommand command = new RelayCommand( () => { actionPerformed = true; }); Assert.That(command.HasCanExecuteFunction, Is.False); Assert.That(command.CanExecute(null), Is.True); command.Execute(null); Assert.That(command.CanExecute(null), Is.True); Assert.That(actionPerformed, Is.True); }