public void InvokeCommandAgainstReactiveCommandInTargetRespectsCanExecuteWindow() { var executed = false; var canExecute = new BehaviorSubject<bool>(false); var fixture = new ReactiveCommandHolder(); var source = new Subject<int>(); source.InvokeCommand(fixture, x => x.TheCommand); fixture.TheCommand = ReactiveCommand.Create<int>(_ => executed = true, canExecute); source.OnNext(0); Assert.False(executed); // The execution window re-opens, but the above execution request should not be instigated because // it occurred when the window was closed. Execution requests do not queue up when the window is closed. canExecute.OnNext(true); Assert.False(executed); }
public void InvokeCommandAgainstReactiveCommandInTargetPassesTheSpecifiedValueToExecute() { var executeReceived = 0; var fixture = new ReactiveCommandHolder(); var source = new Subject<int>(); source.InvokeCommand(fixture, x => x.TheCommand); fixture.TheCommand = ReactiveCommand.Create<int>(x => executeReceived = x); source.OnNext(42); Assert.Equal(42, executeReceived); }
public void InvokeCommandAgainstReactiveCommandInTargetRespectsCanExecute() { var executed = false; var canExecute = new BehaviorSubject<bool>(false); var fixture = new ReactiveCommandHolder(); var source = new Subject<int>(); source.InvokeCommand(fixture, x => x.TheCommand); fixture.TheCommand = ReactiveCommand.Create<int>(_ => executed = true, canExecute); source.OnNext(0); Assert.False(executed); canExecute.OnNext(true); source.OnNext(0); Assert.True(executed); }
public void InvokeCommandAgainstReactiveCommandInTargetInvokesTheCommand() { var executionCount = 0; var fixture = new ReactiveCommandHolder(); var source = new Subject<int>(); source.InvokeCommand(fixture, x => x.TheCommand); fixture.TheCommand = ReactiveCommand.Create<int>(_ => { ++executionCount; }); source.OnNext(0); Assert.Equal(1, executionCount); source.OnNext(0); Assert.Equal(2, executionCount); }