public void CanExecuteReturnsTrueWithoutCanExecuteDelegate() { var handlers = new AsyncDelegateObjectHandlers(); var command = new global::Anori.WinUI.Commands.AsyncRelayCommand <object>(async o => await handlers.Execute(o)); var condition = command.CanExecute(null); Assert.True(condition); }
public void CanExecuteCallsPassedInCanExecuteDelegate() { var handlers = new AsyncDelegateObjectHandlers(); var command = new global::Anori.WinUI.Commands.AsyncRelayCommand <object>(async o => await handlers.Execute(o), handlers.CanExecute); var parameter = new object(); handlers.CanExecuteReturnValue = true; var actual = command.CanExecute(parameter); Assert.AreSame(parameter, handlers.CanExecuteParameter); Assert.AreEqual(handlers.CanExecuteReturnValue, actual); }
public void ShouldPassParameterInstanceOnCanExecute() { var canExecuteCalled = false; var testClass = new MyClass(); ICommand command = new global::Anori.WinUI.Commands.AsyncRelayCommand <MyClass>( async o => await Task.Yield(), delegate(MyClass parameter) { Assert.AreSame(testClass, parameter); canExecuteCalled = true; return(true); }); command.CanExecute(testClass); Assert.True(canExecuteCalled); }