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
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
namespace Spectre.Console.Tests.Unit;
|
|
|
|
[ExpectationPath("Widgets/Columns")]
|
|
public sealed class ColumnsTests
|
|
{
|
|
private sealed class User
|
|
{
|
|
public string Name { get; set; }
|
|
public string Country { get; set; }
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Render")]
|
|
public Task Should_Render_Columns_Correctly()
|
|
{
|
|
// Given
|
|
var console = new TestConsole().Width(61);
|
|
var users = new[]
|
|
{
|
|
new User { Name = "Savannah Thompson", Country = "Australia" },
|
|
new User { Name = "Sophie Ramos", Country = "United States" },
|
|
new User { Name = "Katrin Goldberg", Country = "Germany" },
|
|
};
|
|
|
|
var cards = new List<Panel>();
|
|
foreach (var user in users)
|
|
{
|
|
cards.Add(
|
|
new Panel($"[b]{user.Name}[/]\n[yellow]{user.Country}[/]")
|
|
.RoundedBorder().Expand());
|
|
}
|
|
|
|
// When
|
|
console.Write(new Columns(cards));
|
|
|
|
// Then
|
|
return Verifier.Verify(console.Output);
|
|
}
|
|
}
|