public void TestInitialFalse() { var notifier = new BooleanNotifier(false); var recorder = new TestScheduler().CreateObserver<bool>(); notifier.Subscribe(recorder); notifier.Value.Is(false); notifier.TurnOn(); notifier.TurnOff(); notifier.Value = true; notifier.Value = true; notifier.Value = false; notifier.TurnOn(); notifier.SwitchValue(); notifier.SwitchValue(); recorder.Messages.Is( OnNext(0, true), OnNext(0, false), OnNext(0, true), OnNext(0, true), OnNext(0, false), OnNext(0, true), OnNext(0, false), OnNext(0, true)); recorder.Messages.Clear(); notifier.TurnOn(); recorder.Messages.Count.Is(0); }
public void TestInitialFalse() { var notifier = new BooleanNotifier(false); var recorder = new TestScheduler().CreateObserver <bool>(); notifier.Subscribe(recorder); notifier.Value.Is(false); notifier.TurnOn(); notifier.TurnOff(); notifier.Value = true; notifier.Value = true; notifier.Value = false; notifier.TurnOn(); notifier.SwitchValue(); notifier.SwitchValue(); recorder.Messages.Is( OnNext(0, true), OnNext(0, false), OnNext(0, true), OnNext(0, true), OnNext(0, false), OnNext(0, true), OnNext(0, false), OnNext(0, true)); recorder.Messages.Clear(); notifier.TurnOn(); recorder.Messages.Count.Is(0); }
public BooleanNotifierViewModel() { ToggleCommand.Subscribe(BooleanNotifier.SwitchValue).AddTo(DisposeCollection); ONCommand.Subscribe(BooleanNotifier.TurnOn).AddTo(DisposeCollection); OFFCommand.Subscribe(BooleanNotifier.TurnOff).AddTo(DisposeCollection); BooleanNotifier.Subscribe(_ => CountNotifier.Increment()).AddTo(DisposeCollection); }