public void TestCallingExecuteWhenCanExecuteIsFalse() { var counter = 0; var command = new RelayCommand( (e) => counter++, (e) => _canExecute); command.Execute(null); Assert.AreEqual(1, counter); _canExecute = false; command.Execute(null); Assert.AreEqual(1, counter); _canExecute = true; command.Execute(null); Assert.AreEqual(2, counter); }
public void TestCallingExecuteWhenCanExecuteIsFalse() { var result = string.Empty; const string value1 = "Hello"; const string value2 = "World"; var command = new RelayCommand<string>( s => result = s, s => _canExecute); command.Execute(value1); Assert.AreEqual(value1, result); _canExecute = false; command.Execute(value2); Assert.AreEqual(value1, result); _canExecute = true; command.Execute(value2); Assert.AreEqual(value2, result); }
public void ExecuteTest() { var dummy = "Not executed"; const string executed = "Executed"; const string parameter = "Parameter"; var command = new RelayCommand<string>(p => { dummy = executed + p; }); command.Execute(parameter); Assert.AreEqual(executed + parameter, dummy); }
public void TestExecute() { var dummy = "Not executed"; const string executed = "Executed"; var command = new RelayCommand((e) => { dummy = executed; }); command.Execute(null); Assert.AreEqual(executed, dummy); }