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
64 lines
1.5 KiB
C#
64 lines
1.5 KiB
C#
namespace Spectre.Console.Tests.Unit;
|
|
|
|
[ExpectationPath("Widgets/BarChart")]
|
|
public sealed class BarChartTests
|
|
{
|
|
[Fact]
|
|
[Expectation("Render")]
|
|
public async Task Should_Render_Correctly()
|
|
{
|
|
// Given
|
|
var console = new TestConsole();
|
|
|
|
// When
|
|
console.Write(new BarChart()
|
|
.Width(60)
|
|
.Label("Number of fruits")
|
|
.AddItem("Apple", 12)
|
|
.AddItem("Orange", 54)
|
|
.AddItem("Banana", 33));
|
|
|
|
// Then
|
|
await Verifier.Verify(console.Output);
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Zero_Value")]
|
|
public async Task Should_Render_Correctly_2()
|
|
{
|
|
// Given
|
|
var console = new TestConsole();
|
|
|
|
// When
|
|
console.Write(new BarChart()
|
|
.Width(60)
|
|
.Label("Number of fruits")
|
|
.AddItem("Apple", 0)
|
|
.AddItem("Orange", 54)
|
|
.AddItem("Banana", 33));
|
|
|
|
// Then
|
|
await Verifier.Verify(console.Output);
|
|
}
|
|
|
|
[Fact]
|
|
[Expectation("Fixed_Max_Value")]
|
|
public async Task Should_Render_Correctly_3()
|
|
{
|
|
// Given
|
|
var console = new TestConsole();
|
|
|
|
// When
|
|
console.Write(new BarChart()
|
|
.Width(60)
|
|
.WithMaxValue(100)
|
|
.Label("Number of fruits")
|
|
.AddItem("Apple", 12)
|
|
.AddItem("Orange", 54)
|
|
.AddItem("Banana", 33));
|
|
|
|
// Then
|
|
await Verifier.Verify(console.Output);
|
|
}
|
|
}
|