public async Task AsyncCommandBase_T_FrameworkMethodsMustBeCalledWithData_ValueType() { ICommand command = new AsyncTestCommand <int>(); bool canExecute = command.CanExecute(240); Assert.True(canExecute); Assert.Throws <NullReferenceException>(() => command.CanExecute(null)); command.Execute(240); await Assert.ThrowsAsync <NullReferenceException>(() => ((AsyncCommandBase <int>)command).InternalExecuteAsync(null)); }
public async Task AsyncCommandBase_T_FrameworkMethodsMustBeCalledWithData_ReferenceType() { ICommand command = new AsyncTestCommand <string>(); bool canExecute = command.CanExecute("240"); Assert.True(canExecute); Assert.Throws <ArgumentNullException>("parameter", () => command.CanExecute(null)); command.Execute("240"); await Assert.ThrowsAsync <ArgumentNullException>("parameter", () => ((AsyncCommandBase <string>)command).InternalExecuteAsync(null)); }
public async Task AsyncCommandBase_FrameworkMethodsMustBeCalledWithoutData() { ICommand command = new AsyncTestCommand(); bool canExecute = command.CanExecute(null); Assert.True(canExecute); Assert.Throws <ArgumentException>("parameter", () => command.CanExecute(240)); command.Execute(null); await Assert.ThrowsAsync <ArgumentException>("parameter", () => ((AsyncCommandBase)command).InternalExecuteAsync(240)); }
public void AsyncCommandBase_T_FrameworkMethodsCallIntoStronglyTypedImplementations() { string? text = null; ICommand command = new AsyncTestCommand <string>(t => text = t, t => { text = t; return(Task.CompletedTask); }); bool canExecute = command.CanExecute(nameof(ICommand.CanExecute)); Assert.Equal("CanExecute", text); Assert.True(canExecute); command.Execute(nameof(ICommand.Execute)); Assert.Equal("Execute", text); }
public void AsyncCommandBase_FrameworkMethodsCallIntoParameterlessImplementations() { string? text = null; ICommand command = new AsyncTestCommand(() => text = nameof(ICommand.CanExecute), () => { text = nameof(ICommand.Execute); return(Task.CompletedTask); }); bool canExecute = command.CanExecute(null); Assert.Equal("CanExecute", text); Assert.True(canExecute); command.Execute(null); Assert.Equal("Execute", text); }