public void Measuring_a_vertical_stack_with_tall_children_trims_last_child()
        {
            var stackLayout = new StackLayoutView(Orientation.Vertical);
            var child1      = new ContentView("The quick");
            var child2      = new ContentView("brown fox");

            stackLayout.Add(child1);
            stackLayout.Add(child2);

            var terminal = new TestTerminal();
            var renderer = new ConsoleRenderer(terminal);

            var size = stackLayout.Measure(renderer, new Size(5, 3));

            size.Should().BeEquivalentTo(new Size(5, 3));
        }
        public void Measuring_a_horizontal_stack_with_truncated_height_measures_max_for_each_child()
        {
            var stackLayout = new StackLayoutView(Orientation.Horizontal);
            var child1      = new ContentView("The quick");
            var child2      = new ContentView("brown fox");

            stackLayout.Add(child1);
            stackLayout.Add(child2);

            var terminal = new TestTerminal();
            var renderer = new ConsoleRenderer(terminal);

            var size = stackLayout.Measure(renderer, new Size(7, 1));

            size.Should().BeEquivalentTo(new Size(7, 1));
        }
        public void Measuring_a_horizontal_stack_with_wide_children_wraps_last_child()
        {
            var stackLayout = new StackLayoutView(Orientation.Horizontal);
            var child1      = new ContentView("The quick");
            var child2      = new ContentView("brown fox");

            stackLayout.Add(child1);
            stackLayout.Add(child2);

            var terminal = new TestTerminal();
            var renderer = new ConsoleRenderer(terminal);

            var size = stackLayout.Measure(renderer, new Size(12, 5));

            size.Should().BeEquivalentTo(new Size(12, 2));
        }
        public void Measuring_a_horizontal_stack_with_word_wrap_it_sums_max_width_for_each_child()
        {
            var stackLayout = new StackLayoutView(Orientation.Horizontal);
            var child1      = new ContentView("The quick");
            var child2      = new ContentView("brown fox");

            stackLayout.Add(child1);
            stackLayout.Add(child2);

            var terminal = new TestTerminal();
            var renderer = new ConsoleRenderer(terminal);

            var size = stackLayout.Measure(renderer, new Size(10, 10));

            size.Should().BeEquivalentTo(new Size(10, 2));
        }
        public void Measuring_a_horizontal_stack_sums_content_width()
        {
            var stackLayout = new StackLayoutView(Orientation.Horizontal);
            var child1      = new ContentView("The quick");
            var child2      = new ContentView("brown fox");

            stackLayout.Add(child1);
            stackLayout.Add(child2);

            var terminal = new TestTerminal();
            var renderer = new ConsoleRenderer(terminal);

            var size = stackLayout.Measure(renderer, new Size(20, 20));

            size.Should().BeEquivalentTo(new Size("The quickbrown fox".Length, 1));
        }
        public void Measuring_a_vertical_stack_with_word_wrap_it_sums_max_height_for_each_row()
        {
            var stackLayout = new StackLayoutView(Orientation.Vertical);
            var child1      = new ContentView("The quick");
            var child2      = new ContentView("brown fox");

            stackLayout.Add(child1);
            stackLayout.Add(child2);

            var terminal = new TestTerminal();
            var renderer = new ConsoleRenderer(terminal);

            var size = stackLayout.Measure(renderer, new Size(7, 10));

            size.Should().BeEquivalentTo(new Size("brown ".Length, 4));
        }
        public void Measuring_a_vertical_stack_sums_content_height()
        {
            var stackLayout = new StackLayoutView(Orientation.Vertical);
            var child1      = new ContentView("The quick");
            var child2      = new ContentView("brown fox");

            stackLayout.Add(child1);
            stackLayout.Add(child2);

            var terminal = new TestTerminal();
            var renderer = new ConsoleRenderer(terminal);

            var size = stackLayout.Measure(renderer, new Size(10, 10));

            size.Should().BeEquivalentTo(new Size(9, 2));
        }
        public void Measuring_a_vertical_stack_with_row_truncation_the_top_row_is_measured_first()
        {
            var stackLayout = new StackLayoutView(Orientation.Vertical);
            var child1      = new ContentView("The quick");
            var child2      = new ContentView("brown fox");

            stackLayout.Add(child1);
            stackLayout.Add(child2);

            var terminal = new TestTerminal();
            var renderer = new ConsoleRenderer(terminal);

            var size = stackLayout.Measure(renderer, new Size(7, 1));

            var firstViewTopRow = "The ".Length;

            size.Should().BeEquivalentTo(new Size(firstViewTopRow, 1));
        }