mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-03 11:18:16 +08:00
Add Layout widget (#1041)
* Add width to panels * Add height to panels * Replace RenderContext with RenderOptions * Remove exclusivity from alternative buffer * Add Layout widget * Add Align widget
This commit is contained in:
@ -81,7 +81,7 @@ public sealed class PanelTests
|
||||
// When
|
||||
console.Write(new Panel("Hello World")
|
||||
{
|
||||
Header = new PanelHeader("Greeting").LeftAligned(),
|
||||
Header = new PanelHeader("Greeting").LeftJustified(),
|
||||
Expand = true,
|
||||
});
|
||||
|
||||
@ -117,7 +117,7 @@ public sealed class PanelTests
|
||||
// When
|
||||
console.Write(new Panel("Hello World")
|
||||
{
|
||||
Header = new PanelHeader("Greeting").RightAligned(),
|
||||
Header = new PanelHeader("Greeting").RightJustified(),
|
||||
Expand = true,
|
||||
});
|
||||
|
||||
@ -204,6 +204,76 @@ public sealed class PanelTests
|
||||
return Verifier.Verify(console.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Render_Width")]
|
||||
public Task Should_Render_To_Specified_Width()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
|
||||
// When
|
||||
console.Write(new Panel(new Text("Hello World"))
|
||||
{
|
||||
Width = 25,
|
||||
});
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(console.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Render_Width_MaxWidth")]
|
||||
public Task Should_Use_Max_Width_If_Specified_Width_Is_Too_Large()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
console.Profile.Width = 20;
|
||||
|
||||
// When
|
||||
console.Write(new Panel(new Text("Hello World"))
|
||||
{
|
||||
Width = 25,
|
||||
});
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(console.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Render_Height")]
|
||||
public Task Should_Render_To_Specified_Height()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
|
||||
// When
|
||||
console.Write(new Panel(new Text("Hello World\nHello Hello Hello"))
|
||||
{
|
||||
Height = 25,
|
||||
});
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(console.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Render_Width_Height")]
|
||||
public Task Should_Render_To_Specified_Width_And_Height()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
|
||||
// When
|
||||
console.Write(new Panel("Hello World\nHello Hello Hello")
|
||||
{
|
||||
Width = 50,
|
||||
Height = 25,
|
||||
});
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(console.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Render_Child_RightAligned")]
|
||||
public Task Should_Justify_Child_To_Right_Correctly()
|
||||
@ -213,7 +283,7 @@ public sealed class PanelTests
|
||||
|
||||
// When
|
||||
console.Write(
|
||||
new Panel(new Text("Hello World").RightAligned())
|
||||
new Panel(new Text("Hello World").RightJustified())
|
||||
{
|
||||
Expand = true,
|
||||
});
|
||||
|
Reference in New Issue
Block a user