Пример #1
0
        public void ConnectingChangesValue()
        {
            var connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.Connect(parent);
            connectableProperty.Value.Should().Be(1);
        }
Пример #2
0
        public void ParentValueChangesTriggerValueChangeInConnectableProperty()
        {
            var connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.Connect(parent);

            parent.Value = 2;
            connectableProperty.Value.Should().Be(2);
        }
Пример #3
0
        private void connectableProperty()
        {
            var connectable = new ConnectableProperty <int>(0);
            var a           = new StoredProperty <int>(8);

            Console.WriteLine(connectable.Value); // 0
            connectable.Connect(a);
            Console.WriteLine(connectable.Value); // 8
        }
Пример #4
0
        public void DisconnectingResetsValueToDisconnectedValue()
        {
            var connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.Connect(parent);
            connectableProperty.Value.Should().Be(1, "before disconnecting");

            connectableProperty.Disconnect();
            connectableProperty.Value.Should().Be(0, "after disconnecting");
        }
Пример #5
0
        public void ConnectingWithSameValueDoesNotFireChange()
        {
            bool eventFired          = false;
            var  connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.PropertyChanged += delegate { eventFired = true; };

            connectableProperty.Connect(new StoredProperty <int>(0));
            eventFired.Should().BeFalse();
        }
Пример #6
0
        public void ConnectingWithDifferentValueFiresChange()
        {
            bool eventFired          = false;
            var  connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.PropertyChanged += delegate { eventFired = true; };

            connectableProperty.Connect(parent);
            eventFired.Should().BeTrue();
        }
Пример #7
0
        public void DisconnectingWithSameValueResetsValueToDisconnectedValue()
        {
            var connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.Connect(new StoredProperty <int>(0));
            connectableProperty.Value.Should().Be(0, "before disconnecting");

            connectableProperty.Disconnect();
            connectableProperty.Value.Should().Be(0, "after disconnecting");
        }
Пример #8
0
        public void DisconnectingFiresChange()
        {
            bool eventFired          = false;
            var  connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.Connect(parent);
            connectableProperty.PropertyChanged += delegate { eventFired = true; };
            eventFired.Should().BeFalse("have not disconnected yet");

            connectableProperty.Disconnect();
            eventFired.Should().BeTrue("disconnected");
        }
Пример #9
0
        public void ParentValueChangesTriggerChangeEventsInConnectableProperty()
        {
            bool eventFired          = false;
            var  connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.Connect(parent);
            connectableProperty.PropertyChanged += delegate { eventFired = true; };
            eventFired.Should().BeFalse("haven't changed the parent property yet");

            parent.Value = 2;
            eventFired.Should().BeTrue("parent event changed");
        }
Пример #10
0
        public void DisconnectingWithSameValueDoesNotFireChange()
        {
            bool eventFired          = false;
            var  connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.Connect(new StoredProperty <int>(0));
            connectableProperty.PropertyChanged += delegate { eventFired = true; };
            eventFired.Should().BeFalse("have not disconnected yet");

            connectableProperty.Disconnect();
            eventFired.Should().BeFalse("disconnected, but the value should not have changed from 0 to 0");
        }
Пример #11
0
        public void InitialValue()
        {
            var connectableProperty = new ConnectableProperty <int>(0);

            connectableProperty.Value.Should().Be(0, "before connecting");
        }
Пример #12
0
 set => SetValue(ConnectableProperty, value);