Ejemplo n.º 1
0
        public void Attaching_Control_To_Tree_Invalidates_Parent_Measure()
        {
            var target  = new Mock <ILayoutManager>();
            var control = new Decorator();
            var root    = new LayoutTestRoot
            {
                Child         = control,
                LayoutManager = target.Object,
            };

            root.Measure(Size.Infinity);
            root.Arrange(new Rect(root.DesiredSize));
            Assert.True(control.IsMeasureValid);

            root.Child = null;
            root.Measure(Size.Infinity);
            root.Arrange(new Rect(root.DesiredSize));

            Assert.False(control.IsMeasureValid);
            Assert.True(root.IsMeasureValid);

            target.Invocations.Clear();

            root.Child = control;

            Assert.False(root.IsMeasureValid);
            Assert.False(control.IsMeasureValid);
            target.Verify(x => x.InvalidateMeasure(root), Times.Once());
        }
Ejemplo n.º 2
0
        public void Only_Calls_LayoutManager_InvalidateArrange_Once()
        {
            var target  = new Mock <ILayoutManager>();
            var control = new Decorator();
            var root    = new LayoutTestRoot
            {
                Child         = control,
                LayoutManager = target.Object,
            };

            root.Measure(Size.Infinity);
            root.Arrange(new Rect(root.DesiredSize));
            target.Invocations.Clear();

            control.InvalidateArrange();
            control.InvalidateArrange();

            target.Verify(x => x.InvalidateArrange(control), Times.Once());
        }