public void INotifyPropertyChanged_ChangeValueOfUpdateProperty_ChangedEventCalled() { var notifier = new NotifiesOfPropertyChanges(); var called = false; notifier.PropertyChanged += (s, e) => called = true; notifier.UpdatableIntProperty = NotifiesOfPropertyChanges.InitialUpdatableIntPropertyValue + 1; Assert.True(called); }
public void INotifyPropertyChanged_DoNotChangeValueOfAssignProperty_ChangedEventNotCalled() { var notifier = new NotifiesOfPropertyChanges(); var called = false; notifier.PropertyChanged += (s, e) => called = true; notifier.AssignProperty = NotifiesOfPropertyChanges.InitialAssignPropertyValue; Assert.False(called); }
public void INotifyPropertyChanged_DoNotChangeValueOfPreUpdateActionProperty_ChangedEventNotCalled() { var notifier = new NotifiesOfPropertyChanges(); Assert.Equal(NotifiesOfPropertyChanges.InitialExecutedPreUpdateActionValue, notifier.ExecutedPreUpdateAction); var called = false; notifier.PropertyChanged += (s, e) => called = true; notifier.PreUpdateActionProperty = NotifiesOfPropertyChanges.InitialPreUpdateActionPropertyValue; Assert.False(called); Assert.Equal(NotifiesOfPropertyChanges.InitialExecutedPreUpdateActionValue, notifier.ExecutedPreUpdateAction); }
public void INotifyPropertyChanged_ChangeValueOfPostUpdateProperty_ChangedEventCalledAndPostUpdateActionExecuted() { var notifier = new NotifiesOfPropertyChanges(); Assert.Equal(NotifiesOfPropertyChanges.InitialExecutedPostUpdateActionValue, notifier.ExecutedPostUpdateAction); var called = false; notifier.PropertyChanged += (s, e) => called = true; notifier.PostUpdateActionProperty = NotifiesOfPropertyChanges.InitialPostUpdateActionPropertyValue + 1; Assert.True(called); Assert.Equal(NotifiesOfPropertyChanges.InitialPostUpdateActionPropertyValue + 1, notifier.ExecutedPostUpdateAction); }
public void INotifyPropertyChanged_DoNotChangeValueOfPostAssignProperty_ChangedEventAndPostAssignActionNotCalled() { var notifier = new NotifiesOfPropertyChanges(); Assert.False(notifier.ExecutedPostAssignAction); var called = false; notifier.PropertyChanged += (s, e) => called = true; notifier.PostAssignActionProperty = NotifiesOfPropertyChanges.InitialPostAssignActionPropertyValue; Assert.False(called); Assert.False(notifier.ExecutedPostAssignAction); }
public void INotifyPropertyChanged_ChangeValueOfAssignProperty_ChangedEventCalledAndValueChanged() { var notifier = new NotifiesOfPropertyChanges(); var called = 0; notifier.PropertyChanged += (s, e) => ++ called; notifier.AssignProperty = NotifiesOfPropertyChanges.InitialAssignPropertyValue + 1; notifier.ChangeMe = null; notifier.ChangeMe = "I'm baaaack!"; Assert.Equal(3, called); Assert.Equal(NotifiesOfPropertyChanges.InitialAssignPropertyValue + 1, notifier.AssignProperty); }
public void INotifyPropertyChanged_RaisePropertyChanges_PropertyChangeEventsFire() { var notifier = new NotifiesOfPropertyChanges(); var update1 = false; var update2 = false; var update3 = false; var update4 = false; notifier.PropertyChanged += (s, e) => { Assert.Equal("UpdatableIntProperty", e.PropertyName); switch (notifier.UpdatableIntProperty) { case NotifiesOfPropertyChanges.InitialUpdatableIntPropertyValue + 1: update1 = true; break; case NotifiesOfPropertyChanges.InitialUpdatableIntPropertyValue + 2: update2 = true; break; case NotifiesOfPropertyChanges.InitialUpdatableIntPropertyValue + 3: update3 = true; break; case NotifiesOfPropertyChanges.InitialUpdatableIntPropertyValue + 4: update4 = true; break; default: Assert.True(false, "Unexpected value for notifier.UpdatableIntProperty: " + notifier.UpdatableIntProperty); break; } }; var postRaiseEvent = false; notifier.RaisePropertyChangedEventsForUpdatableIntProperty((_, v) => postRaiseEvent = true); Assert.True(update1); Assert.True(update2); Assert.True(update3); Assert.True(update4); Assert.True(postRaiseEvent); }