Ejemplo n.º 1
0
        public void ViewsArrangedWithDesiredHeights()
        {
            var stack   = CreateTestLayout();
            var manager = new HorizontalStackLayoutManager(stack);

            var view1 = CreateTestView(new Size(100, 200));
            var view2 = CreateTestView(new Size(100, 150));

            var children = new List <IView>()
            {
                view1, view2
            }.AsReadOnly();

            stack.Children.Returns(children);

            var measurement = manager.Measure(double.PositiveInfinity, double.PositiveInfinity);

            manager.Arrange(new Rectangle(Point.Zero, measurement));

            // The tallest IView is 200, so the stack should be that tall
            Assert.Equal(200, measurement.Height);

            // We expect the first IView to be at 0,0 with a width of 100 and a height of 200
            var expectedRectangle1 = new Rectangle(0, 0, 100, 200);

            view1.Received().Arrange(Arg.Is(expectedRectangle1));

            // We expect the second IView to be at 100, 0 with a width of 100 and a height of 150
            var expectedRectangle2 = new Rectangle(100, 0, 100, 150);

            view2.Received().Arrange(Arg.Is(expectedRectangle2));
        }
Ejemplo n.º 2
0
        public void SpacingArrangementOneItem(int spacing)
        {
            var stack = BuildStack(1, 100, 100);

            stack.Spacing.Returns(spacing);

            var manager = new HorizontalStackLayoutManager(stack);

            var measuredSize = manager.Measure(double.PositiveInfinity, 100);

            manager.Arrange(new Rectangle(Point.Zero, measuredSize));

            var expectedRectangle = new Rectangle(0, 0, 100, 100);

            stack.Children[0].Received().Arrange(Arg.Is(expectedRectangle));
        }
Ejemplo n.º 3
0
        public void RtlShouldHaveFirstItemOnTheRight()
        {
            var stack = BuildStack(viewCount: 2, viewWidth: 100, viewHeight: 100);

            stack.FlowDirection.Returns(FlowDirection.RightToLeft);

            var manager      = new HorizontalStackLayoutManager(stack);
            var measuredSize = manager.Measure(double.PositiveInfinity, 100);

            manager.Arrange(new Rectangle(Point.Zero, measuredSize));

            // We expect that the starting view (0) should be arranged on the right,
            // and the next rectangle (1) should be on the left
            var expectedRectangle0 = new Rectangle(100, 0, 100, 100);
            var expectedRectangle1 = new Rectangle(0, 0, 100, 100);

            stack.Children[0].Received().Arrange(Arg.Is(expectedRectangle0));
            stack.Children[1].Received().Arrange(Arg.Is(expectedRectangle1));
        }