public void Test_PropertyChanged_Raises_Multiple_CanExecuteChange() { ClearAll(); var dispatcher = new InlineMockMainThreadDispatcher(); Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(dispatcher); var testObject = new SharedCommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var calledByAttrCommand = collection["CalledByAttr"]; Assert.IsNotNull(calledByAttrCommand); var countAttr = 0; calledByAttrCommand.CanExecuteChanged += (sender, args) => countAttr++; var calledByAttr2Command = collection["CalledByAttr2"]; Assert.IsNotNull(calledByAttr2Command); var countAttr2 = 0; calledByAttr2Command.CanExecuteChanged += (sender, args) => countAttr2++; testObject.RaisePropertyChanged("CanExecuteAttributed"); Assert.AreEqual(1, countAttr); Assert.AreEqual(1, countAttr2); testObject.RaisePropertyChanged("CanExecuteAttributed"); Assert.AreEqual(2, countAttr); Assert.AreEqual(2, countAttr2); }
public void Test_PropertyChanged_Raises_Multiple_CanExecuteChange() { ClearAll(); var testObject = new SharedCommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var calledByAttrCommand = collection["CalledByAttr"]; Assert.IsNotNull(calledByAttrCommand); var countAttr = 0; calledByAttrCommand.CanExecuteChanged += (sender, args) => countAttr++; var calledByAttr2Command = collection["CalledByAttr2"]; Assert.IsNotNull(calledByAttr2Command); var countAttr2 = 0; calledByAttr2Command.CanExecuteChanged += (sender, args) => countAttr2++; testObject.RaisePropertyChanged("CanExecuteAttributed"); Assert.AreEqual(1, countAttr); Assert.AreEqual(1, countAttr2); testObject.RaisePropertyChanged("CanExecuteAttributed"); Assert.AreEqual(2, countAttr); Assert.AreEqual(2, countAttr2); }