public void FireAdditionalPropertyChangedProperly()
        {
            var eventAFired = false;
            var eventBFired = false;

            var vm = new TestObservableObject();

            vm.PropertyChanged += (obj, e) =>
            {
                Assert.IsNotNull(e);
                if (e.PropertyName == "A")
                {
                    eventAFired = true;
                }
            };
            vm.PropertyChanged += (obj, e) =>
            {
                Assert.IsNotNull(e);
                if (e.PropertyName == "B")
                {
                    eventBFired = true;
                }
            };

            vm.A++;

            Assert.IsTrue(eventAFired);
            Assert.IsTrue(eventBFired);
        }
        public void AllowHookingIntoThePropertyChangedProcessing()
        {
            var vm = new TestObservableObject();

            Assert.AreEqual(0, vm.OnPropertyChangedCallCount);

            vm.A = 1;
            Assert.AreEqual(2, vm.OnPropertyChangedCallCount);
        }
        public void NotFirePropertyChangedWhenValueSetIsTheSame()
        {
            var vm = new TestObservableObject();

            vm.PropertyChanged += CallCounter;

            Assert.AreEqual(0, _callCounter);

            var value = vm.PropertyRaisingChangeNotification;

            vm.PropertyRaisingChangeNotification = value;

            Assert.AreEqual(0, _callCounter);
        }
        public void ProperlySuspendPropertyChangedEvent()
        {
            var vm = new TestObservableObject();

            vm.PropertyChanged += CallCounter;

            Assert.AreEqual(0, _callCounter);

            using (vm.SuspendPropertyChangedEvent(CallCounter))
            {
                vm.PropertyRaisingChangeNotification++;
                Assert.AreEqual(0, _callCounter);
            }

            vm.PropertyRaisingChangeNotification++;
            Assert.AreEqual(1, _callCounter);
        }
        public void FirePropertyChangeNotificationWhenUsingSetWithTwoParameters()
        {
            var eventFired = false;

            var vm = new TestObservableObject();

            vm.PropertyChanged += (obj, e) =>
            {
                Assert.IsNotNull(e);
                Assert.AreEqual("SetWith2Parameters", e.PropertyName);
                eventFired = true;
            };

            Assert.AreNotEqual(13, vm.PropertyRaisingChangeNotification);

            vm.SetWith2Parameters(13);

            Assert.IsTrue(eventFired);
        }
        public void NotCrashIfAdditionalPropertiesChangedIsNull()
        {
            var vm = new TestObservableObject();

            Assert.DoesNotThrow(() => vm.NullAdditionalProperties());
        }