mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00

* Add support for C# 12 * Run all tests on all major .NET SDKs * Only build on Ubuntu * Do not build docs for pull requests * Add Cédric Luthi, and Frank Ray to authors * Drop netstandard2.0 for ImageSharp plugin
152 lines
4.3 KiB
C#
152 lines
4.3 KiB
C#
using Spectre.Console.Extensions;
|
|
|
|
namespace Spectre.Console.Tests.Unit;
|
|
|
|
[ExpectationPath("Widgets/Align")]
|
|
public sealed class AlignTests
|
|
{
|
|
public sealed class Left
|
|
{
|
|
[Fact]
|
|
[Expectation("Left_Top")]
|
|
public Task Should_Render_Panel_Left_Aligned_At_Top()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Left(new Panel("Hello World!"), VerticalAlignment.Top).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Left_Middle")]
|
|
public Task Should_Render_Panel_Left_Aligned_At_Middle()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Left(new Panel("Hello World!"), VerticalAlignment.Middle).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Left_Bottom")]
|
|
public Task Should_Render_Panel_Left_Aligned_At_Bottom()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Left(new Panel("Hello World!"), VerticalAlignment.Bottom).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
}
|
|
|
|
public sealed class Center
|
|
{
|
|
[Fact]
|
|
[Expectation("Center_Top")]
|
|
public Task Should_Render_Panel_Center_Aligned_At_Top()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Center(new Panel("Hello World!"), VerticalAlignment.Top).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Center_Middle")]
|
|
public Task Should_Render_Panel_Center_Aligned_At_Middle()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Center(new Panel("Hello World!"), VerticalAlignment.Middle).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Center_Bottom")]
|
|
public Task Should_Render_Panel_Center_Aligned_At_Bottom()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Center(new Panel("Hello World!"), VerticalAlignment.Bottom).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
}
|
|
|
|
public sealed class Right
|
|
{
|
|
[Fact]
|
|
[Expectation("Right_Top")]
|
|
public Task Should_Render_Panel_Right_Aligned_At_Top()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Right(new Panel("Hello World!"), VerticalAlignment.Top).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Right_Middle")]
|
|
public Task Should_Render_Panel_Right_Aligned_At_Middle()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Right(new Panel("Hello World!"), VerticalAlignment.Middle).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Right_Bottom")]
|
|
public Task Should_Render_Panel_Right_Aligned_At_Bottom()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Size(new Size(40, 15));
|
|
var align = Align.Right(new Panel("Hello World!"), VerticalAlignment.Bottom).Height(15);
|
|
|
|
// When
|
|
console.Write(align);
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
}
|
|
}
|