spectre.console/test/Spectre.Console.Tests/Unit/AnsiConsoleTests.Advanced.cs
Patrik Svensson c9b178ac96 Moved analyzer tests to its own project
Also moves tests to `./test` which makes it possible
for all test projects to share the same .editorconfig
files and similar.
2021-06-23 22:47:12 +02:00

62 lines
1.8 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Shouldly;
using Spectre.Console.Advanced;
using Spectre.Console.Testing;
using Xunit;
namespace Spectre.Console.Tests.Unit
{
public sealed partial class AnsiConsoleTests
{
public sealed class Advanced
{
[Fact]
public void Should_Write_Ansi_Codes_To_Console_If_Supported()
{
// Given
var console = new TestConsole()
.SupportsAnsi(true)
.Colors(ColorSystem.Standard)
.EmitAnsiSequences();
// When
console.WriteAnsi("Hello");
// Then
console.Output.NormalizeLineEndings()
.ShouldBe("Hello");
}
[Fact]
public void Should_Not_Write_Ansi_Codes_To_Console_If_Not_Supported()
{
// Given
var console = new TestConsole()
.SupportsAnsi(false)
.Colors(ColorSystem.Standard)
.EmitAnsiSequences();
// When
console.WriteAnsi("Hello");
// Then
console.Output.NormalizeLineEndings()
.ShouldBeEmpty();
}
[Fact]
public void Should_Return_Ansi_For_Renderable()
{
// Given
var console = new TestConsole().Colors(ColorSystem.TrueColor);
var markup = new Console.Markup("[yellow]Hello [blue]World[/]![/]");
// When
var result = console.ToAnsi(markup);
// Then
result.ShouldBe("Hello World!");
}
}
}
}