Exemple #1
0
        public void DescendantAddedExistingChildren()
        {
            var root = new TestElement();

            var tier2 = new TestElement();

            var child = new TestElement
            {
                Children =
                {
                    tier2
                }
            };

            bool tier1added = false;
            bool tier2added = false;

            root.DescendantAdded += (sender, args) =>
            {
                if (!tier1added)
                {
                    tier1added = ReferenceEquals(child, args.Element);
                }
                if (!tier2added)
                {
                    tier2added = ReferenceEquals(tier2, args.Element);
                }
            };

            root.Children.Add(child);

            Assert.That(tier1added, Is.True);
            Assert.That(tier2added, Is.True);
        }
Exemple #2
0
        public void DescendantAddedLevel1()
        {
            var root = new TestElement();

            var child = new TestElement();

            bool added = false;

            root.DescendantAdded += (sender, args) =>
            {
                Assert.That(args.Element, Is.SameAs(child));
                added = true;
            };

            root.Children.Add(child);
        }
Exemple #3
0
        public void DescendantRemovedLevel2()
        {
            var root = new TestElement();

            var child = new TestElement();

            root.Children.Add(child);

            var child2 = new TestElement();

            child.Children.Add(child2);

            bool removed = false;

            root.DescendantRemoved += (sender, args) =>
            {
                Assert.That(args.Element, Is.SameAs(child2));
                removed = true;
            };

            child.Children.Remove(child2);
        }