public void ExecuteNotifies() { var invokeCount = 0; var isExecutingCount = 0; var command = new ManualRelayCommand(() => invokeCount++, () => true); command.ObservePropertyChangedSlim(nameof(command.IsExecuting), false) .Subscribe(_ => isExecutingCount++); Assert.IsFalse(command.IsExecuting); Assert.True(command.CanExecute()); command.Execute(); Assert.IsFalse(command.IsExecuting); Assert.True(command.CanExecute()); Assert.AreEqual(1, invokeCount); Assert.AreEqual(2, isExecutingCount); }
public static void ExecuteNotifies() { var invokeCount = 0; var isExecutingCount = 0; var command = new ManualRelayCommand <int>(i => invokeCount += i, _ => true); using (command.ObservePropertyChangedSlim(nameof(command.IsExecuting), signalInitial: false) .Subscribe(_ => isExecutingCount++)) { Assert.IsFalse(command.IsExecuting); Assert.True(command.CanExecute(1)); command.Execute(1); Assert.IsFalse(command.IsExecuting); Assert.True(command.CanExecute(1)); Assert.AreEqual(1, invokeCount); Assert.AreEqual(2, isExecutingCount); } }