Example #1
0
        public void Callback_Is_Called_On_Direct_Property_Change()
        {
            bool isCallbackCalled = false;
            var  first            = ObservedPropertyModels.CreateFirst("text");

            Action callback = () => isCallbackCalled = true;

            var property = ObservedProperty.Create(() => first.Second.Third.Value, callback);

            first.Second.Third.Value = "new";

            Assert.True(isCallbackCalled);
        }
Example #2
0
        public void ObservedProperty_Dispose_Works()
        {
            bool isCallbackCalled = false;
            var  first            = ObservedPropertyModels.CreateFirst("text");

            Action callback = () => isCallbackCalled = true;

            var property = ObservedProperty.Create(() => first.Second.Third.Value, callback);

            property.Dispose();

            first.Second = ObservedPropertyModels.CreateSecond("new1");

            Assert.False(isCallbackCalled);
        }
Example #3
0
        public void ObservedProperty_Suppress_Works()
        {
            bool isCallbackCalled = false;
            var  first            = ObservedPropertyModels.CreateFirst("text");

            Action callback = () => isCallbackCalled = true;

            var property = ObservedProperty.Create(() => first.Second.Third.Value, callback);

            using (property.Suppress())
                first.Second = ObservedPropertyModels.CreateSecond("new");

            Assert.False(isCallbackCalled);

            first.Second = ObservedPropertyModels.CreateSecond("new1");

            Assert.True(isCallbackCalled);
        }