Exemplo n.º 1
0
        public void UnsubscribeFromOldItemOnReplace()
        {
            var eventedList = new EventedList <MockClassWithTwoProperties>();

            var aPropertyChangeCount    = 0;
            var listPropertyChangeCount = 0;

            var a = new MockClassWithTwoProperties {
                StringProperty = "a"
            };

            eventedList.Add(a);

            eventedList.PropertyChanged += delegate { listPropertyChangeCount++; };
            a.PropertyChanged           += delegate { aPropertyChangeCount++; };

            // replace item
            eventedList[0] = new MockClassWithTwoProperties {
                StringProperty = "second a"
            };

            a.StringProperty = "a2";

            Assert.AreEqual(0, listPropertyChangeCount);
            Assert.AreEqual(1, aPropertyChangeCount);
        }
Exemplo n.º 2
0
        public void ListShouldSubscribeToPropertyChangesInChildObjectAfterAddRange()
        {
            var eventedList = new EventedList <MockClassWithTwoProperties>();

            //add three integers to the list.
            var properties = new MockClassWithTwoProperties();

            eventedList.AddRange(new[] { properties });

            object theSender = null;
            PropertyChangedEventArgs theEventArgs = null;

            eventedList.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { theSender    = sender;
                                                                                                 theEventArgs = e; };
            properties.StringProperty = "iets";
            Assert.AreEqual(properties, theSender);
            Assert.AreEqual("StringProperty", theEventArgs.PropertyName);
        }
Exemplo n.º 3
0
        public void UnsubscribeFromOldItemOnReplace()
        {
            var eventedList = new EventedList<MockClassWithTwoProperties>();

            var aPropertyChangeCount = 0;
            var listPropertyChangeCount = 0;

            var a = new MockClassWithTwoProperties {StringProperty = "a"};

            eventedList.Add(a);

            eventedList.PropertyChanged += delegate { listPropertyChangeCount++; };
            a.PropertyChanged += delegate { aPropertyChangeCount++; };

            // replace item
            eventedList[0] = new MockClassWithTwoProperties {StringProperty = "second a"};

            a.StringProperty = "a2";

            Assert.AreEqual(0, listPropertyChangeCount);
            Assert.AreEqual(1, aPropertyChangeCount);
        }
Exemplo n.º 4
0
        public void ListShouldSubscribeToPropertyChangesInChildObjectAfterAdd()
        {
            var eventedList = new EventedList<MockClassWithTwoProperties>();

            //add three integers to the list.
            var properties = new MockClassWithTwoProperties();
            eventedList.Add( properties );

            object theSender = null;
            PropertyChangedEventArgs theEventArgs = null;
            eventedList.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
                                               {
                                                   theSender = sender;
                                                   theEventArgs = e;
                                               };
            properties.StringProperty = "iets";
            Assert.AreEqual(properties, theSender);
            Assert.AreEqual("StringProperty", theEventArgs.PropertyName);
        }