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_column_definition() { var columnDefinition = ColumnDefinition.Fixed(1); columnDefinition.Value.Should().Be(1.0); columnDefinition.SizeMode.Should().Be(SizeMode.Fixed); }
public void Fixed_sized_column_definition_can_be_zero() { var columnDefinition = ColumnDefinition.Fixed(0); columnDefinition.Value.Should().Be(0); columnDefinition.SizeMode.Should().Be(SizeMode.Fixed); }
public void Column_width_definition_is_preserved_even_defintion_is_mixed_for_subsequent_columns(OutputMode outputMode) { var grid = new GridView(); grid.SetColumns(ColumnDefinition.Fixed(10), ColumnDefinition.Star(1), ColumnDefinition.Fixed(10), ColumnDefinition.SizeToContent()); grid.SetChild(new ContentView("The quick"), 0, 0); grid.SetChild(new ContentView("brown fox"), 1, 0); grid.SetChild(new ContentView("jumped"), 2, 0); grid.SetChild(new ContentView("over the sleepy"), 3, 0); var terminal = new TestTerminal(); var renderer = new ConsoleRenderer(terminal, outputMode); grid.Render(renderer, new Region(0, 0, 121, 1)); terminal.Events.Should().BeEquivalentSequenceTo( new TestTerminal.CursorPositionChanged(new Point(0, 0)), new TestTerminal.ContentWritten("The quick "), new TestTerminal.CursorPositionChanged(new Point(10, 0)), new TestTerminal.ContentWritten(" "), new TestTerminal.CursorPositionChanged(new Point(12, 0)), new TestTerminal.ContentWritten("brown fox" + new string(' ', 71)), new TestTerminal.CursorPositionChanged(new Point(92, 0)), new TestTerminal.ContentWritten(" "), new TestTerminal.CursorPositionChanged(new Point(94, 0)), new TestTerminal.ContentWritten("jumped "), new TestTerminal.CursorPositionChanged(new Point(104, 0)), new TestTerminal.ContentWritten(" "), new TestTerminal.CursorPositionChanged(new Point(106, 0)), new TestTerminal.ContentWritten("over the sleepy")); }
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_column_definition_negative_weight_throws() { Action createNegativeWeight = () => ColumnDefinition.Fixed(-1); createNegativeWeight.Should().Throw <ArgumentException>(); }
public void Column_width_definition_size_calculation_according_priority_fixed_then_size_to_content_then_star(OutputMode outputMode) { var grid = new GridView(); grid.SetColumns(ColumnDefinition.Star(1), ColumnDefinition.SizeToContent(), ColumnDefinition.Fixed(10)); grid.SetChild(new ContentView("The quick"), 0, 0); grid.SetChild(new ContentView("brown fox"), 1, 0); grid.SetChild(new ContentView("jumped"), 2, 0); var terminal = new TestTerminal(); var renderer = new ConsoleRenderer(terminal, outputMode); grid.Render(renderer, new Region(0, 0, 22, 1)); terminal.Events.Should().BeEquivalentSequenceTo( new TestTerminal.CursorPositionChanged(new Point(0, 0)), new TestTerminal.ContentWritten("brown fox"), new TestTerminal.CursorPositionChanged(new Point(9, 0)), new TestTerminal.ContentWritten(" "), new TestTerminal.CursorPositionChanged(new Point(11, 0)), new TestTerminal.ContentWritten("jumped ")); }