Ejemplo n.º 1
0
        public void HasValueWorks()
        {
            var component = Mock.Of <IDependencyComponent>();
            var prop      = Mock.Of <IDependencyProperty>();
            var store     = new LocalValueStore(component, 0);

            Assert.False(store.HasValue(prop));

            store.SetValue(prop, "value");

            Assert.True(store.HasValue(prop));

            store.SetValue(prop, "other value");

            Assert.True(store.HasValue(prop));

            store.ClearValue(prop);

            Assert.False(store.HasValue(prop));

            store.SetValue(prop, "reassign value");

            Assert.True(store.HasValue(prop));
        }
Ejemplo n.º 2
0
        public void CanClearValue()
        {
            var component = Mock.Of <IDependencyComponent>();
            var prop      = Mock.Of <IDependencyProperty>();
            var store     = new LocalValueStore(component, 0);

            store.SetValue(prop, "value");

            var raised = 0;

            store.ValueChanged += (s, e) =>
            {
                Assert.Same(component, e.Component);
                Assert.Equal(Maybe.FromValue <object>("value"), e.OldValue);
                Assert.Equal(Maybe.None <object>(), e.NewValue);

                raised++;
            };

            store.ClearValue(prop);

            Assert.Equal(1, raised);
            Assert.False(store.HasValue(prop));
        }