public void Fixed_grid_lays_out_fixed_rows_and_columns(OutputMode outputMode) { var grid = new GridView(); grid.SetColumns(ColumnDefinition.Fixed(6), ColumnDefinition.Fixed(4)); grid.SetRows(RowDefinition.Fixed(1), RowDefinition.Fixed(2)); grid.SetChild(new ContentView("The quick"), 0, 0); grid.SetChild(new ContentView("brown fox"), 1, 0); grid.SetChild(new ContentView("jumped over"), 0, 1); grid.SetChild(new ContentView("the sleepy"), 1, 1); var terminal = new TestTerminal(); var renderer = new ConsoleRenderer(terminal, outputMode); grid.Render(renderer, new Region(0, 0, 10, 4)); terminal.Events .Should() .BeEquivalentSequenceTo( new TestTerminal.CursorPositionChanged(new Point(0, 0)), new TestTerminal.ContentWritten("The "), new TestTerminal.CursorPositionChanged(new Point(6, 0)), new TestTerminal.ContentWritten("brow"), new TestTerminal.CursorPositionChanged(new Point(0, 1)), new TestTerminal.ContentWritten("jumped"), new TestTerminal.CursorPositionChanged(new Point(0, 2)), new TestTerminal.ContentWritten("over "), new TestTerminal.CursorPositionChanged(new Point(6, 1)), new TestTerminal.ContentWritten("the "), new TestTerminal.CursorPositionChanged(new Point(6, 2)), new TestTerminal.ContentWritten("slee")); }
public void Can_create_fixed_sized_row_definition() { var rowDefinition = RowDefinition.Fixed(1); rowDefinition.Value.Should().Be(1.0); rowDefinition.SizeMode.Should().Be(SizeMode.Fixed); }
public void Fixed_sized_row_definition_can_be_zero() { var rowDefinition = RowDefinition.Fixed(0); rowDefinition.Value.Should().Be(0); rowDefinition.SizeMode.Should().Be(SizeMode.Fixed); }
public void Row_height_definition_size_calculation_according_priority_fixed_then_size_to_content_then_star(OutputMode outputMode) { var grid = new GridView(); grid.SetRows(RowDefinition.Star(1), RowDefinition.SizeToContent(), RowDefinition.Fixed(4)); grid.SetChild(new ContentView("The"), 0, 0); grid.SetChild(new ContentView("quick brown fox"), 0, 1); grid.SetChild(new ContentView("jumped over the sleepy"), 0, 2); var terminal = new TestTerminal(); var renderer = new ConsoleRenderer(terminal, outputMode); grid.Render(renderer, new Region(0, 0, 8, 6)); terminal.Events.Should().BeEquivalentSequenceTo( new TestTerminal.CursorPositionChanged(new Point(0, 0)), new TestTerminal.ContentWritten("quick "), new TestTerminal.CursorPositionChanged(new Point(0, 1)), new TestTerminal.ContentWritten("brown "), new TestTerminal.CursorPositionChanged(new Point(0, 2)), new TestTerminal.ContentWritten("jumped "), new TestTerminal.CursorPositionChanged(new Point(0, 3)), new TestTerminal.ContentWritten("over the"), new TestTerminal.CursorPositionChanged(new Point(0, 4)), new TestTerminal.ContentWritten("sleepy "), new TestTerminal.CursorPositionChanged(new Point(0, 5)), new TestTerminal.ContentWritten(" ")); }
public void Empty_fixed_sized_grid_returns_fixed_region() { var grid = new GridView(); grid.SetColumns(ColumnDefinition.Fixed(7), ColumnDefinition.Star(3)); grid.SetRows(RowDefinition.Fixed(3), RowDefinition.Star(7)); var console = new TestConsole(); var renderer = new ConsoleRenderer(console); Size measuredSize = grid.Measure(renderer, new Size(10, 10)); measuredSize.Width.Should().Be(10); measuredSize.Height.Should().Be(10); }
public void Fixed_sized_row_definition_negative_weight_throws() { Action createNegativeWeight = () => RowDefinition.Fixed(-1); createNegativeWeight.Should().Throw <ArgumentException>(); }