public void Constructor_Default_ReturnsICommand() { var func = Execute.Create(); var command = Command.Create(func); Assert.IsAssignableFrom <ICommand>(command); }
public void Constructor_Default_ReturnsIAsyncCommandGeneric() { var func = Execute.Create <string>(); var command = Command.Create(func); Assert.IsAssignableFrom <IAsyncCommand <string> >(command); }
public void CanExecute_NotNullDelegate_ReturnsExpectedValue(object parameter, bool expected) { var func = Execute.Create<string>(); var command = Command.Create(func, _ => expected); Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, parameter, expected); }
public void CanExecute_WithNullParameter_ReturnsTrue() { var func = Execute.Create(); var command = Command.Create(func); Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, null, true); }
public void CanExecute_NotNullDelegate_ReturnsExpectedValue(bool expected) { var func = Execute.Create(); var command = Command.Create(func, () => expected); Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, null, expected); }
public void CanExecuteChanged_ExecuteWasFinished_RisesOnce() { var func = Execute.Create <string>(); var command = Command.Create(func); Assert_CanExecuteChanged_AfterExecute_RisesOnce(command); }
public void CanExecute_WithUnsupportedParameters_IgnoresParameter(object parameter) { var func = Execute.Create(); var command = Command.Create(func); Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, parameter, true); }
public void CanExecute_DefaultWithParameters_ReturnsTrue(object parameter) { var func = Execute.Create<string>(); var command = Command.Create(func); Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, parameter, true); }
public void Constructor_Default_ReturnsIRaisableCanExecute() { var func = Execute.Create <string>(); var command = Command.Create(func); Assert.IsAssignableFrom <IRaisableCanExecute>(command); }
public void CanExecute_DefaultWithParameters_WhenTypesMismatch_ReturnsFalse() { var func = Execute.Create<string>(); var command = Command.Create(func); Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, 123, false); }
public async Task ExecuteAsync_AsyncWithException_ThrowsException(string parameter) { var func = Execute.WithException <string>(); var command = Command.Create(func); await Assert.ThrowsAsync <InvalidOperationException>(() => command.ExecuteAsync(parameter)); }
public async Task ExecuteAsync_AsyncWithException_ThrowsException() { var func = Execute.WithException(); var command = Command.Create(func); await Assert.ThrowsAsync <InvalidOperationException>(() => command.ExecuteAsync(null)); }
public void Execute_CanExecuteFalse_DoNotExecutes(string parameter) { var func = Execute.Create <string>(); var command = Command.Create(func, _ => false); command.Execute(parameter); func.DidNotReceive().Invoke(parameter); }
public void Execute_CanExecuteFalse_DoesNotExecute() { var func = Execute.Create(); var command = Command.Create(func, () => false); command.Execute(null); func.DidNotReceive().Invoke(); }
public void Execute_CanExecuteTrue_ExecutesOneTime() { var func = Execute.Create(); var command = Command.Create(func, () => true); command.Execute(null); func.Received(1).Invoke(); }
public void Execute_WithNotNullParameter_IgnoresParameter(object parameter) { var func = Execute.Create(); var command = Command.Create(func); command.Execute(parameter); func.Received(1).Invoke(); }
public void Execute_CalledOneTime_ExecutesOneTime() { var func = Execute.Create(); var command = Command.Create(func); command.Execute(null); func.Received(1).Invoke(); }
public void Execute_AsICommand_Executes(string parameter) { var func = Execute.Create <string>(); var command = Command.Create(func) as ICommand; command.Execute(parameter); func.Received(1).Invoke(parameter); }
public void Execute_AsyncWithException_ExecutesWithoutException() { var func = Execute.WithException(); var command = Command.Create(func); command.Execute(null); func.Received(1).Invoke(); }
public async Task ExecuteAsync_CalledOneTime_ExecutesOneTime(string parameter) { var func = Execute.Create <string>(); var command = Command.Create(func); await command.ExecuteAsync(parameter); await func.Received(1).Invoke(parameter); }
public async Task ExecuteAsync_WithUnsupportedParameter_IgnoresParameter(object parameter) { var func = Execute.Create(); var command = Command.Create(func); await command.ExecuteAsync(parameter); await func.Received(1).Invoke(); }
public async Task ExecuteAsync_CalledOneTime_ExecutesOneTime() { var func = Execute.Create(); var command = Command.Create(func); await command.ExecuteAsync(null); await func.Received(1).Invoke(); }
public void Execute_CanExecuteTrue_ExecutesOneTime(string parameter) { var func = Execute.Create <string>(); var command = Command.Create(func, _ => true); command.Execute(parameter); func.Received(1).Invoke(parameter); }
public void Execute_AsyncWithException_ExecutesWithoutException(string parameter) { var func = Execute.WithException <string>(); var command = Command.Create(func); command.Execute(parameter); func.Received(1).Invoke(parameter); }
public void Execute_AsICommandGenericWithNullableStruct_Executes(int?parameter) { var func = Execute.Create <int?>(); var command = Command.Create(func) as ICommand <int?>; command.Execute(parameter); func.Received(1).Invoke(parameter); }
public void CanExecute_WhileExecuting_ReturnsFalse() { var tcs = new TaskCompletionSource<bool>(); var func = Execute.FromSource<string>(tcs); var command = Command.Create(func); Assert_CanExecute_AfterExecuteWithParameter_ReturnsExpectedValue(command, null, false); tcs.SetResult(true); }
public void Execute_SyncCallTwoTimes_ExecutesTwoTimes(string parameter) { var func = Execute.Create <string>(); var command = Command.Create(func); command.Execute(parameter); command.Execute(parameter); func.Received(2).Invoke(parameter); }
public void Execute_SyncCallTwoTimes_ExecutesTwoTimes() { var func = Execute.Create(); var command = Command.Create(func); command.Execute(null); command.Execute(null); func.Received(2).Invoke(); }
public void Execute_WithUnsupportedParameterType_IgnoresParameter <TCommand, TParameter>( TCommand commandType, TParameter parameter) { var func = Execute.Create <TCommand>(); var command = Command.Create(func); command.Execute(parameter); func.DidNotReceive().Invoke(Arg.Any <TCommand>()); }
public void Execute_AsyncCallSeveralTimes_ExecutesOneTime() { var tcs = new TaskCompletionSource <bool>(); var func = Execute.FromSource(tcs); var command = Command.Create(func); command.Execute(null); command.Execute(null); command.Execute(null); func.Received(1).Invoke(); tcs.SetResult(true); }