public void Measure_Adjusts_DesiredSize_Upwards_When_Constraint_Allows(double desiredSize, double expectedSize)
        {
            var target = new TestLayoutable(new Size(desiredSize, desiredSize));
            var root   = CreateRoot(1.5, target);

            root.LayoutManager.ExecuteInitialLayoutPass();

            Assert.Equal(new Size(expectedSize, expectedSize), target.DesiredSize);
        }
        public void Measure_Constrains_Adjusted_DesiredSize_To_Constraint()
        {
            var target = new TestLayoutable(new Size(101, 101));
            var root   = CreateRoot(1.5, target, constraint: new Size(101, 101));

            root.LayoutManager.ExecuteInitialLayoutPass();

            // Desired width/height with layout rounding is 101.3333 but constraint is 101,101 so
            // layout rounding should be ignored.
            Assert.Equal(new Size(101, 101), target.DesiredSize);
        }
        public void Arrange_Adjusts_Bounds_Upwards_With_Margin()
        {
            var target = new TestLayoutable(new Size(101, 101), margin: 1);
            var root   = CreateRoot(1.5, target);

            root.LayoutManager.ExecuteInitialLayoutPass();

            // - 1 pixel margin is rounded up to 1.3333
            // - Size of 101 gets rounded up to 101.3333
            AssertEqual(new Point(1.3333333333333333, 1.3333333333333333), target.Bounds.Position);
            AssertEqual(new Size(101.33333333333333, 101.33333333333333), target.Bounds.Size);
        }
        public void Measure_Adjusts_DesiredSize_Upwards_When_Margin_Present()
        {
            var target = new TestLayoutable(new Size(101, 101), margin: 1);
            var root   = CreateRoot(1.5, target);

            root.LayoutManager.ExecuteInitialLayoutPass();

            // - 1 pixel margin is rounded up to 1.3333; for both sides it is 2.6666
            // - Size of 101 gets rounded up to 101.3333
            // - Final size = 101.3333 + 2.6666 = 104
            AssertEqual(new Size(104, 104), target.DesiredSize);
        }
        public void VerticalAlignment_Is_Applied_To_ArrangeOverride_Size(
            VerticalAlignment v,
            double expectedHeight)
        {
            var target = new TestLayoutable
            {
                VerticalAlignment = v,
            };

            target.Measure(Size.Infinity);
            target.Arrange(new Rect(0, 0, 100, 100));

            Assert.Equal(new Size(100, expectedHeight), target.ArrangeSize);
        }
        public void HorizontalAlignment_Is_Applied_To_ArrangeOverride_Size(
            HorizontalAlignment h,
            double expectedWidth)
        {
            var target = new TestLayoutable
            {
                HorizontalAlignment = h,
            };

            target.Measure(Size.Infinity);
            target.Arrange(new Rect(0, 0, 100, 100));

            Assert.Equal(new Size(expectedWidth, 100), target.ArrangeSize);
        }
        public void Margin_Is_Applied_To_MeasureOverride_Size(
            double l,
            double t,
            double r,
            double b,
            double expectedWidth,
            double expectedHeight)
        {
            var target = new TestLayoutable
            {
                Margin = new Thickness(l, t, r, b),
            };

            target.Measure(new Size(100, 100));

            Assert.Equal(new Size(expectedWidth, expectedHeight), target.MeasureSize);
        }