public void RegisteredPreInterceptorGetsCalled() { var wasCalled = false; NotifyPropertyChangedCore.RegisterPreInterceptor((sender, e) => wasCalled = true); try { var unitUnderTest = new NotificationOnlyDummy(); unitUnderTest.NotificationOnlyProperty = 42; Assert.IsTrue(wasCalled); } finally { NotifyPropertyChangedCore.ClearInterceptors(); } }
public void PlainPropertyIsMaxXXXTimesFasterThanNotificationOnlyPropertyWithoutHandler() { var plain = new NotifyPropertyChangedDummy(); var dummy = new NotificationOnlyDummy(); int count = 0; var actual = Measure.ExecutionTimeFactor( () => plain.PlainProperty = count++, () => dummy.NotificationOnlyProperty = count++ ); var maximumFactor = 7.5d; actual.Factor.AssertNear(maximumFactor, 2); }
public void NotificationOnlyPropertyWithEmptyHandlerIsNearlyAsFastAsNotificationOnlyPropertyWithoutHandler() { var withoutHandler = new NotificationOnlyDummy(); var withHandler = new NotificationOnlyDummy(); withHandler.PropertyChanged += (sender, e) => { ; }; int count = 0; var actual = Measure.ExecutionTimeFactor( () => withoutHandler.NotificationOnlyProperty = count++, () => withHandler.NotificationOnlyProperty = count++ ); var maximumFactor = 1d; actual.Factor.AssertNear(maximumFactor, 0.2); }
public void StaticPreInterceptorsAreCalledBeforeInstancePreInterceptors() { var wasCalled = false; NotifyPropertyChangedCore.RegisterPreInterceptor((sender, e) => wasCalled = true); try { var unitUnderTest = new NotificationOnlyDummy(); var interceptable = (IPropertyInterceptor)unitUnderTest; var staticWasCalledBeforeInstance = false; interceptable.PreSet += (sender, e) => staticWasCalledBeforeInstance = wasCalled; unitUnderTest.NotificationOnlyProperty = 42; Assert.IsTrue(staticWasCalledBeforeInstance); } finally { NotifyPropertyChangedCore.ClearInterceptors(); } }