Example #1
0
        public void PreSetInterceptorUsesUnitUnderTestAsSender()
        {
            var unitUnderTest = CreateUnitUnderTest();

            bool senderIsUnitUnderTest = false;

            NotifyPropertyChangedCore.RegisterPreInterceptor((sender, e) => senderIsUnitUnderTest = object.ReferenceEquals(sender, unitUnderTest));
            try {
                unitUnderTest.ChangeAwareNotificationProperty = 42;

                Assert.IsTrue(senderIsUnitUnderTest);
            }
            finally {
                NotifyPropertyChangedCore.ClearInterceptors();
            }
        }
Example #2
0
        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();
            }
        }
Example #3
0
        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();
            }
        }