spectre.console
spectre.console copied to clipboard
Center aligned FigletText throws System.OutOfMemoryException exception when run with CommandAppTester
Information
- OS: Windows 10
- Version: Spectre.Console 0.49.1, XUnit 2.9.3
- Terminal: Windows Terminal
Describe the bug
Center aligned FigletText throws System.OutOfMemoryException when run with CommandAppTester.
To Reproduce Run the below, self-contained, unit test:
using Spectre.Console;
using Spectre.Console.Cli;
using Spectre.Console.Testing;
using Xunit;
public class HelloCommand : Command
{
private IAnsiConsole console;
public HelloCommand(IAnsiConsole console)
{
this.console = console;
}
public override int Execute(CommandContext context)
{
console.Write(
new FigletText("Hello")
.Centered()
.Color(Color.Red));
return 0;
}
}
public class Tests
{
[Fact]
public void Should_Output_Centered_FigletText()
{
// Given
var app = new CommandAppTester();
app.Configure(config => config.PropagateExceptions());
app.SetDefaultCommand<HelloCommand>();
// When
var result = app.Run();
// Then
Assert.Equal(0, result.ExitCode);
}
}
Expected behavior Should output centered FigletText ie:
[xUnit.net 00:00:00.13] Starting: ConsoleApp1
_ _ _ _
| | | | ___ | | | | ___
| |_| | / _ \ | | | | / _ \
| _ | | __/ | | | | | (_) |
|_| |_| \___| |_| |_| \___/
[xUnit.net 00:00:00.21] Finished: ConsoleApp1
The following test that uses AnsiConsole executes correctly FYI:
public void Should_Output_Centered_FigletText()
{
AnsiConsole.Write(
new FigletText("Hello")
.Centered()
.Color(Color.Red));
}
Screenshots
Additional context
The following line in CommandAppTester is the culprit:
Which overrides the TestConsole default of 80 lines:
And causes the out of memory exception in RenderableExtensions.cs:
Please upvote :+1: this issue if you are interested in it.