Пример #1
0
        public void TestRaiseChild()
        {
            var view = new NaiveLayout();

            var child1 = new View();
            var child2 = new View();
            var child3 = new View();

            view.Children.Add(child1);
            view.Children.Add(child2);
            view.Children.Add(child3);

            bool reordered = false;

            view.ChildrenReordered += (sender, args) => reordered = true;

            view.RaiseChild(child1);

            Assert.AreEqual(child1, ((IElementController)view).LogicalChildren [2]);
            Assert.True(reordered);

            view.RaiseChild(child2);
            Assert.AreEqual(child2, ((IElementController)view).LogicalChildren [2]);
        }
Пример #2
0
        public void TestRaiseUnownedChild()
        {
            var view = new NaiveLayout();

            var child1 = new View();
            var child2 = new View();
            var child3 = new View();

            view.Children.Add(child1);
            view.Children.Add(child3);

            bool reordered = false;

            view.ChildrenReordered += (sender, args) => reordered = true;

            view.RaiseChild(child2);

            Assert.False(reordered);
        }
Пример #3
0
        public void ReorderChildrenDoesNotRaiseChildAddedOrRemoved()
        {
            var child1 = new BoxView();
            var child2 = new BoxView();
            var layout = new NaiveLayout {
                Children = { child1, child2 }
            };

            var added   = false;
            var removed = false;

            layout.ChildAdded   += (sender, args) => added = true;
            layout.ChildRemoved += (sender, args) => removed = true;

            layout.RaiseChild(child1);

            Assert.False(added);
            Assert.False(removed);
        }