public void InvokeCommandAgainstReactiveCommandInTargetPassesTheSpecifiedValueToExecute() { int executeReceived = 0; ReactiveCommandHolder fixture = new ReactiveCommandHolder(); Subject <int> source = new Subject <int>(); source.InvokeCommand(fixture, x => x.TheCommand); fixture.TheCommand = ReactiveCommand.Create <int>(x => executeReceived = x, outputScheduler: ImmediateScheduler.Instance); source.OnNext(42); Assert.Equal(42, executeReceived); }
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 InvokeCommandAgainstReactiveCommandInTargetInvokesTheCommand() { int executionCount = 0; ReactiveCommandHolder fixture = new ReactiveCommandHolder(); Subject <int> source = new Subject <int>(); source.InvokeCommand(fixture, x => x.TheCommand); fixture.TheCommand = ReactiveCommand.Create <int>(_ => { ++executionCount; }, outputScheduler: ImmediateScheduler.Instance); source.OnNext(0); Assert.Equal(1, executionCount); source.OnNext(0); Assert.Equal(2, executionCount); }
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); }
public void InvokeCommandAgainstReactiveCommandInTargetRespectsCanExecute() { bool executed = false; BehaviorSubject <bool> canExecute = new BehaviorSubject <bool>(false); ReactiveCommandHolder fixture = new ReactiveCommandHolder(); Subject <int> source = new Subject <int>(); source.InvokeCommand(fixture, x => x.TheCommand); fixture.TheCommand = ReactiveCommand.Create <int>(_ => executed = true, canExecute, ImmediateScheduler.Instance); source.OnNext(0); Assert.False(executed); canExecute.OnNext(true); source.OnNext(0); Assert.True(executed); }
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 InvokeCommandAgainstReactiveCommandInTargetRespectsCanExecuteWindow() { bool executed = false; BehaviorSubject <bool> canExecute = new BehaviorSubject <bool>(false); ReactiveCommandHolder fixture = new ReactiveCommandHolder(); Subject <int> source = new Subject <int>(); source.InvokeCommand(fixture, x => x.TheCommand); fixture.TheCommand = ReactiveCommand.Create <int>(_ => executed = true, canExecute, ImmediateScheduler.Instance); 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 InvokeCommandAgainstReactiveCommandInTargetSwallowsExceptions() { var count = 0; var fixture = new ReactiveCommandHolder(); fixture.TheCommand = ReactiveCommand.Create <int>( _ => { ++count; throw new InvalidOperationException(); }); fixture.TheCommand.ThrownExceptions.Subscribe(); var source = new Subject <int>(); source.InvokeCommand(fixture, x => x.TheCommand); source.OnNext(0); source.OnNext(0); Assert.Equal(2, count); }
public void InvokeCommandAgainstReactiveCommandInTargetSwallowsExceptions() { int count = 0; ReactiveCommandHolder fixture = new ReactiveCommandHolder { TheCommand = ReactiveCommand.Create <int>( _ => { ++count; throw new InvalidOperationException(); }, outputScheduler: ImmediateScheduler.Instance) }; fixture.TheCommand.ThrownExceptions.Subscribe(); Subject <int> source = new Subject <int>(); source.InvokeCommand(fixture, x => x.TheCommand); source.OnNext(0); source.OnNext(0); Assert.Equal(2, count); }