diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c939ba5..c67b41a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -82,4 +82,12 @@ jobs: shell: bash run: | dotnet tool restore - dotnet cake \ No newline at end of file + dotnet cake + + - name: Upload Verify Test Results + if: failure() + uses: actions/upload-artifact@v2 + with: + name: verify-test-results + path: | + **/*.received.* \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3be7708..06993f2 100644 --- a/.gitignore +++ b/.gitignore @@ -88,3 +88,5 @@ packages # Windows Thumbs.db + +*.received.* \ No newline at end of file diff --git a/src/Spectre.Console.Tests/Spectre.Console.Tests.csproj b/src/Spectre.Console.Tests/Spectre.Console.Tests.csproj index 5c43420..de28ce9 100644 --- a/src/Spectre.Console.Tests/Spectre.Console.Tests.csproj +++ b/src/Spectre.Console.Tests/Spectre.Console.Tests.csproj @@ -1,13 +1,14 @@ - net5.0;netcoreapp3.1 + net5.0 false + all @@ -19,4 +20,12 @@ + + + $([System.String]::Copy('%(FileName)').Split('.')[0]) + $(ProjectExt.Replace('proj', '')) + %(ParentFile)%(ParentExtension) + + + diff --git a/src/Spectre.Console.Tests/Tools/PlainConsole.cs b/src/Spectre.Console.Tests/Tools/PlainConsole.cs index 6e9defa..f076db4 100644 --- a/src/Spectre.Console.Tests/Tools/PlainConsole.cs +++ b/src/Spectre.Console.Tests/Tools/PlainConsole.cs @@ -25,9 +25,8 @@ namespace Spectre.Console.Tests public string Link { get; set; } public StringWriter Writer { get; } - public string RawOutput => Writer.ToString(); - public string Output => Writer.ToString().TrimEnd('\n'); - public IReadOnlyList Lines => Output.Split(new char[] { '\n' }); + public string Output => Writer.ToString(); + public IReadOnlyList Lines => Output.TrimEnd('\n').Split(new char[] { '\n' }); public PlainConsole( int width = 80, int height = 9000, Encoding encoding = null, @@ -61,15 +60,13 @@ namespace Spectre.Console.Tests Writer.Write(segment.Text); } - public string[] WriteExceptionAndGetLines(Exception ex, ExceptionFormats formats = ExceptionFormats.Default) + public string WriteNormalizedException(Exception ex, ExceptionFormats formats = ExceptionFormats.Default) { this.WriteException(ex, formats); - - return Output.NormalizeStackTrace() + return string.Join("\n", Output.NormalizeStackTrace() .NormalizeLineEndings() .Split(new char[] { '\n' }) - .Select(line => line.TrimEnd()) - .ToArray(); + .Select(line => line.TrimEnd())); } } } diff --git a/src/Spectre.Console.Tests/Unit/BoxBorderTests.AsciiBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/BoxBorderTests.AsciiBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..4e167a9 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/BoxBorderTests.AsciiBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,3 @@ ++-Greeting----+ +| Hello World | ++-------------+ diff --git a/src/Spectre.Console.Tests/Unit/BoxBorderTests.DoubleBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/BoxBorderTests.DoubleBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..1a9eb50 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/BoxBorderTests.DoubleBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,3 @@ +╔═Greeting════╗ +║ Hello World ║ +╚═════════════╝ diff --git a/src/Spectre.Console.Tests/Unit/BoxBorderTests.HeavyBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/BoxBorderTests.HeavyBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..703f1c5 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/BoxBorderTests.HeavyBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,3 @@ +┏━Greeting━━━━┓ +┃ Hello World ┃ +┗━━━━━━━━━━━━━┛ diff --git a/src/Spectre.Console.Tests/Unit/BoxBorderTests.NoBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/BoxBorderTests.NoBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..684af3c --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/BoxBorderTests.NoBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,3 @@ + Greeting + Hello World + diff --git a/src/Spectre.Console.Tests/Unit/BoxBorderTests.RoundedBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/BoxBorderTests.RoundedBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..000dd12 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/BoxBorderTests.RoundedBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,3 @@ +╭─Greeting────╮ +│ Hello World │ +╰─────────────╯ diff --git a/src/Spectre.Console.Tests/Unit/BoxBorderTests.SquareBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/BoxBorderTests.SquareBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..db45100 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/BoxBorderTests.SquareBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,3 @@ +┌─Greeting────┐ +│ Hello World │ +└─────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/BoxBorderTests.cs b/src/Spectre.Console.Tests/Unit/BoxBorderTests.cs index fa14415..ed48994 100644 --- a/src/Spectre.Console.Tests/Unit/BoxBorderTests.cs +++ b/src/Spectre.Console.Tests/Unit/BoxBorderTests.cs @@ -1,11 +1,15 @@ +using System.Threading.Tasks; using Shouldly; using Spectre.Console.Rendering; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class BoxBorderTests { + [UsesVerify] public sealed class NoBorder { public sealed class TheSafeGetBorderMethod @@ -22,7 +26,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -32,13 +36,11 @@ namespace Spectre.Console.Tests.Unit console.Render(panel); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe(" Greeting "); - console.Lines[1].ShouldBe(" Hello World "); - console.Lines[2].ShouldBe(" "); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class AsciiBorder { public sealed class TheSafeGetBorderMethod @@ -55,7 +57,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -65,13 +67,11 @@ namespace Spectre.Console.Tests.Unit console.Render(panel); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("+-Greeting----+"); - console.Lines[1].ShouldBe("| Hello World |"); - console.Lines[2].ShouldBe("+-------------+"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class DoubleBorder { public sealed class TheSafeGetBorderMethod @@ -88,7 +88,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -98,13 +98,11 @@ namespace Spectre.Console.Tests.Unit console.Render(panel); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("╔═Greeting════╗"); - console.Lines[1].ShouldBe("║ Hello World ║"); - console.Lines[2].ShouldBe("╚═════════════╝"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class HeavyBorder { public sealed class TheSafeGetBorderMethod @@ -121,7 +119,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -131,13 +129,11 @@ namespace Spectre.Console.Tests.Unit console.Render(panel); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┏━Greeting━━━━┓"); - console.Lines[1].ShouldBe("┃ Hello World ┃"); - console.Lines[2].ShouldBe("┗━━━━━━━━━━━━━┛"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class RoundedBorder { [Fact] @@ -151,7 +147,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -161,13 +157,11 @@ namespace Spectre.Console.Tests.Unit console.Render(panel); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("╭─Greeting────╮"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("╰─────────────╯"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class SquareBorder { [Fact] @@ -181,7 +175,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -191,10 +185,7 @@ namespace Spectre.Console.Tests.Unit console.Render(panel); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌─Greeting────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└─────────────┘"); + return Verifier.Verify(console.Output); } } diff --git a/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Center_Calendar_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Center_Calendar_Correctly.verified.txt new file mode 100644 index 0000000..6642b0e --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Center_Calendar_Correctly.verified.txt @@ -0,0 +1,11 @@ + 2020 October + ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐ + │ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ + ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤ + │ │ │ │ │ 1 │ 2 │ 3* │ + │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ + │ 11 │ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │ + │ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │ + │ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ + │ │ │ │ │ │ │ │ + └─────┴─────┴─────┴─────┴─────┴─────┴─────┘ diff --git a/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Left_Align_Calendar_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Left_Align_Calendar_Correctly.verified.txt new file mode 100644 index 0000000..cd1324d --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Left_Align_Calendar_Correctly.verified.txt @@ -0,0 +1,11 @@ + 2020 October +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ │ │ │ │ 1 │ 2 │ 3* │ +│ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ +│ 11 │ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │ +│ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │ +│ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ +│ │ │ │ │ │ │ │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┘ diff --git a/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Render_Calendar_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Render_Calendar_Correctly.verified.txt new file mode 100644 index 0000000..cd1324d --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Render_Calendar_Correctly.verified.txt @@ -0,0 +1,11 @@ + 2020 October +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ │ │ │ │ 1 │ 2 │ 3* │ +│ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ +│ 11 │ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │ +│ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │ +│ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ +│ │ │ │ │ │ │ │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┘ diff --git a/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Render_Calendar_Correctly_For_Specific_Culture.verified.txt b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Render_Calendar_Correctly_For_Specific_Culture.verified.txt new file mode 100644 index 0000000..fd24021 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Render_Calendar_Correctly_For_Specific_Culture.verified.txt @@ -0,0 +1,11 @@ + Oktober 2020 +┌─────┬────┬────┬────┬────┬────┬────┐ +│ Mo │ Di │ Mi │ Do │ Fr │ Sa │ So │ +├─────┼────┼────┼────┼────┼────┼────┤ +│ │ │ │ 1 │ 2 │ 3* │ 4 │ +│ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ +│ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │ 18 │ +│ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │ 25 │ +│ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ │ +│ │ │ │ │ │ │ │ +└─────┴────┴────┴────┴────┴────┴────┘ diff --git a/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Right_Align_Calendar_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Right_Align_Calendar_Correctly.verified.txt new file mode 100644 index 0000000..8a5c82e --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/CalendarTests.Should_Right_Align_Calendar_Correctly.verified.txt @@ -0,0 +1,11 @@ + 2020 October + ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐ + │ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ + ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤ + │ │ │ │ │ 1 │ 2 │ 3* │ + │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ + │ 11 │ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │ + │ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │ + │ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ + │ │ │ │ │ │ │ │ + └─────┴─────┴─────┴─────┴─────┴─────┴─────┘ diff --git a/src/Spectre.Console.Tests/Unit/CalendarTests.cs b/src/Spectre.Console.Tests/Unit/CalendarTests.cs index fa5cc3d..0c8d6a6 100644 --- a/src/Spectre.Console.Tests/Unit/CalendarTests.cs +++ b/src/Spectre.Console.Tests/Unit/CalendarTests.cs @@ -1,13 +1,15 @@ using System; -using Shouldly; +using System.Threading.Tasks; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class CalendarTests { [Fact] - public void Should_Render_Calendar_Correctly() + public Task Should_Render_Calendar_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -20,22 +22,11 @@ namespace Spectre.Console.Tests.Unit console.Render(calendar); // Then - console.Lines.Count.ShouldBe(11); - console.Lines[00].ShouldBe(" 2020 October "); - console.Lines[01].ShouldBe("┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐"); - console.Lines[02].ShouldBe("│ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │"); - console.Lines[03].ShouldBe("├─────┼─────┼─────┼─────┼─────┼─────┼─────┤"); - console.Lines[04].ShouldBe("│ │ │ │ │ 1 │ 2 │ 3* │"); - console.Lines[05].ShouldBe("│ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │"); - console.Lines[06].ShouldBe("│ 11 │ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │"); - console.Lines[07].ShouldBe("│ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │"); - console.Lines[08].ShouldBe("│ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │"); - console.Lines[09].ShouldBe("│ │ │ │ │ │ │ │"); - console.Lines[10].ShouldBe("└─────┴─────┴─────┴─────┴─────┴─────┴─────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Center_Calendar_Correctly() + public Task Should_Center_Calendar_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -49,22 +40,11 @@ namespace Spectre.Console.Tests.Unit console.Render(calendar); // Then - console.Lines.Count.ShouldBe(11); - console.Lines[00].ShouldBe(" 2020 October "); - console.Lines[01].ShouldBe(" ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐ "); - console.Lines[02].ShouldBe(" │ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ "); - console.Lines[03].ShouldBe(" ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤ "); - console.Lines[04].ShouldBe(" │ │ │ │ │ 1 │ 2 │ 3* │ "); - console.Lines[05].ShouldBe(" │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ "); - console.Lines[06].ShouldBe(" │ 11 │ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │ "); - console.Lines[07].ShouldBe(" │ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │ "); - console.Lines[08].ShouldBe(" │ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ "); - console.Lines[09].ShouldBe(" │ │ │ │ │ │ │ │ "); - console.Lines[10].ShouldBe(" └─────┴─────┴─────┴─────┴─────┴─────┴─────┘ "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Left_Align_Calendar_Correctly() + public Task Should_Left_Align_Calendar_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -78,22 +58,11 @@ namespace Spectre.Console.Tests.Unit console.Render(calendar); // Then - console.Lines.Count.ShouldBe(11); - console.Lines[00].ShouldBe(" 2020 October "); - console.Lines[01].ShouldBe("┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐"); - console.Lines[02].ShouldBe("│ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │"); - console.Lines[03].ShouldBe("├─────┼─────┼─────┼─────┼─────┼─────┼─────┤"); - console.Lines[04].ShouldBe("│ │ │ │ │ 1 │ 2 │ 3* │"); - console.Lines[05].ShouldBe("│ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │"); - console.Lines[06].ShouldBe("│ 11 │ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │"); - console.Lines[07].ShouldBe("│ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │"); - console.Lines[08].ShouldBe("│ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │"); - console.Lines[09].ShouldBe("│ │ │ │ │ │ │ │"); - console.Lines[10].ShouldBe("└─────┴─────┴─────┴─────┴─────┴─────┴─────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Right_Align_Calendar_Correctly() + public Task Should_Right_Align_Calendar_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -107,22 +76,11 @@ namespace Spectre.Console.Tests.Unit console.Render(calendar); // Then - console.Lines.Count.ShouldBe(11); - console.Lines[00].ShouldBe(" 2020 October "); - console.Lines[01].ShouldBe(" ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐"); - console.Lines[02].ShouldBe(" │ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │"); - console.Lines[03].ShouldBe(" ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤"); - console.Lines[04].ShouldBe(" │ │ │ │ │ 1 │ 2 │ 3* │"); - console.Lines[05].ShouldBe(" │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │"); - console.Lines[06].ShouldBe(" │ 11 │ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │"); - console.Lines[07].ShouldBe(" │ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │"); - console.Lines[08].ShouldBe(" │ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │"); - console.Lines[09].ShouldBe(" │ │ │ │ │ │ │ │"); - console.Lines[10].ShouldBe(" └─────┴─────┴─────┴─────┴─────┴─────┴─────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Calendar_Correctly_For_Specific_Culture() + public Task Should_Render_Calendar_Correctly_For_Specific_Culture() { // Given var console = new PlainConsole(width: 80); @@ -136,18 +94,7 @@ namespace Spectre.Console.Tests.Unit console.Render(calendar); // Then - console.Lines.Count.ShouldBe(11); - console.Lines[00].ShouldBe(" Oktober 2020 "); - console.Lines[01].ShouldBe("┌─────┬────┬────┬────┬────┬────┬────┐"); - console.Lines[02].ShouldBe("│ Mo │ Di │ Mi │ Do │ Fr │ Sa │ So │"); - console.Lines[03].ShouldBe("├─────┼────┼────┼────┼────┼────┼────┤"); - console.Lines[04].ShouldBe("│ │ │ │ 1 │ 2 │ 3* │ 4 │"); - console.Lines[05].ShouldBe("│ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │"); - console.Lines[06].ShouldBe("│ 12* │ 13 │ 14 │ 15 │ 16 │ 17 │ 18 │"); - console.Lines[07].ShouldBe("│ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │ 25 │"); - console.Lines[08].ShouldBe("│ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ │"); - console.Lines[09].ShouldBe("│ │ │ │ │ │ │ │"); - console.Lines[10].ShouldBe("└─────┴────┴────┴────┴────┴────┴────┘"); + return Verifier.Verify(console.Output); } } } diff --git a/src/Spectre.Console.Tests/Unit/ColumnsTests.Should_Render_Columns_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/ColumnsTests.Should_Render_Columns_Correctly.verified.txt new file mode 100644 index 0000000..38831d5 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/ColumnsTests.Should_Render_Columns_Correctly.verified.txt @@ -0,0 +1,4 @@ +╭────────────────────╮ ╭────────────────╮ ╭─────────────────╮ +│ Savannah Thompson │ │ Sophie Ramos │ │ Katrin Goldberg │ +│ Australia │ │ United States │ │ Germany │ +╰────────────────────╯ ╰────────────────╯ ╰─────────────────╯ diff --git a/src/Spectre.Console.Tests/Unit/ColumnsTests.cs b/src/Spectre.Console.Tests/Unit/ColumnsTests.cs index 9d6a455..119cfa8 100644 --- a/src/Spectre.Console.Tests/Unit/ColumnsTests.cs +++ b/src/Spectre.Console.Tests/Unit/ColumnsTests.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; -using Shouldly; +using System.Threading.Tasks; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class ColumnsTests { private sealed class User @@ -13,7 +15,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_Columns_Correctly() + public Task Should_Render_Columns_Correctly() { // Given var console = new PlainConsole(width: 61); @@ -36,11 +38,7 @@ namespace Spectre.Console.Tests.Unit console.Render(new Columns(cards)); // Then - console.Lines.Count.ShouldBe(4); - console.Lines[0].ShouldBe("╭────────────────────╮ ╭────────────────╮ ╭─────────────────╮"); - console.Lines[1].ShouldBe("│ Savannah Thompson │ │ Sophie Ramos │ │ Katrin Goldberg │"); - console.Lines[2].ShouldBe("│ Australia │ │ United States │ │ Germany │"); - console.Lines[3].ShouldBe("╰────────────────────╯ ╰────────────────╯ ╰─────────────────╯"); + return Verifier.Verify(console.Output); } } } diff --git a/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception.verified.txt b/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception.verified.txt new file mode 100644 index 0000000..a0b81bb --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception.verified.txt @@ -0,0 +1,4 @@ +System.InvalidOperationException: Throwing! + at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn + at Spectre.Console.Tests.Unit.ExceptionTests.<>c.b__0_0() in /xyz/ExceptionTests.cs:nn + at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn diff --git a/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Inner_Exception.verified.txt b/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Inner_Exception.verified.txt new file mode 100644 index 0000000..3627f39 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Inner_Exception.verified.txt @@ -0,0 +1,7 @@ +System.InvalidOperationException: Something threw! + System.InvalidOperationException: Throwing! + at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn + at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn + at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn + at Spectre.Console.Tests.Unit.ExceptionTests.<>c.b__3_0() in /xyz/ExceptionTests.cs:nn + at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn diff --git a/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Shortened_Methods.verified.txt b/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Shortened_Methods.verified.txt new file mode 100644 index 0000000..06e5cc6 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Shortened_Methods.verified.txt @@ -0,0 +1,4 @@ +System.InvalidOperationException: Throwing! + at MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn + at b__2_0() in /xyz/ExceptionTests.cs:nn + at GetException(Action action) in /xyz/ExceptionTests.cs:nn diff --git a/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Shortened_Types.verified.txt b/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Shortened_Types.verified.txt new file mode 100644 index 0000000..3ce4a00 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/ExceptionTests.Should_Write_Exception_With_Shortened_Types.verified.txt @@ -0,0 +1,4 @@ +InvalidOperationException: Throwing! + at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn + at Spectre.Console.Tests.Unit.ExceptionTests.<>c.b__1_0() in /xyz/ExceptionTests.cs:nn + at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn diff --git a/src/Spectre.Console.Tests/Unit/ExceptionTests.cs b/src/Spectre.Console.Tests/Unit/ExceptionTests.cs index 43d9fac..5de58e8 100644 --- a/src/Spectre.Console.Tests/Unit/ExceptionTests.cs +++ b/src/Spectre.Console.Tests/Unit/ExceptionTests.cs @@ -1,85 +1,68 @@ using System; -using Shouldly; +using System.Threading.Tasks; using Spectre.Console.Tests.Data; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class ExceptionTests { [Fact] - public void Should_Write_Exception() + public Task Should_Write_Exception() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.MethodThatThrows(null)); // When - var result = console.WriteExceptionAndGetLines(dex); + var result = console.WriteNormalizedException(dex); // Then - result.Length.ShouldBe(4); - result[0].ShouldBe("System.InvalidOperationException: Throwing!"); - result[1].ShouldBe(" at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn"); - result[2].ShouldBe(" at Spectre.Console.Tests.Unit.ExceptionTests.<>c.b__0_0() in /xyz/ExceptionTests.cs:nn"); - result[3].ShouldBe(" at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn"); + return Verifier.Verify(result); } [Fact] - public void Should_Write_Exception_With_Shortened_Types() + public Task Should_Write_Exception_With_Shortened_Types() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.MethodThatThrows(null)); // When - var result = console.WriteExceptionAndGetLines(dex, ExceptionFormats.ShortenTypes); + var result = console.WriteNormalizedException(dex, ExceptionFormats.ShortenTypes); // Then - result.Length.ShouldBe(4); - result[0].ShouldBe("InvalidOperationException: Throwing!"); - result[1].ShouldBe(" at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn"); - result[2].ShouldBe(" at Spectre.Console.Tests.Unit.ExceptionTests.<>c.b__1_0() in /xyz/ExceptionTests.cs:nn"); - result[3].ShouldBe(" at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn"); + return Verifier.Verify(result); } [Fact] - public void Should_Write_Exception_With_Shortened_Methods() + public Task Should_Write_Exception_With_Shortened_Methods() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.MethodThatThrows(null)); // When - var result = console.WriteExceptionAndGetLines(dex, ExceptionFormats.ShortenMethods); + var result = console.WriteNormalizedException(dex, ExceptionFormats.ShortenMethods); // Then - result.Length.ShouldBe(4); - result[0].ShouldBe("System.InvalidOperationException: Throwing!"); - result[1].ShouldBe(" at MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn"); - result[2].ShouldBe(" at b__2_0() in /xyz/ExceptionTests.cs:nn"); - result[3].ShouldBe(" at GetException(Action action) in /xyz/ExceptionTests.cs:nn"); + return Verifier.Verify(result); } [Fact] - public void Should_Write_Exception_With_Inner_Exception() + public Task Should_Write_Exception_With_Inner_Exception() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.ThrowWithInnerException()); // When - var result = console.WriteExceptionAndGetLines(dex); + var result = console.WriteNormalizedException(dex); // Then - result.Length.ShouldBe(7); - result[0].ShouldBe("System.InvalidOperationException: Something threw!"); - result[1].ShouldBe(" System.InvalidOperationException: Throwing!"); - result[2].ShouldBe(" at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn"); - result[3].ShouldBe(" at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn"); - result[4].ShouldBe(" at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn"); - result[5].ShouldBe(" at Spectre.Console.Tests.Unit.ExceptionTests.<>c.b__3_0() in /xyz/ExceptionTests.cs:nn"); - result[6].ShouldBe(" at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn"); + return Verifier.Verify(result); } public static Exception GetException(Action action) diff --git a/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Explicit_Grid_Column_Padding_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Explicit_Grid_Column_Padding_Correctly.verified.txt new file mode 100644 index 0000000..8c951cf --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Explicit_Grid_Column_Padding_Correctly.verified.txt @@ -0,0 +1,3 @@ + Foo Bar Baz + Qux Corgi Waldo + GraultGarplyFred diff --git a/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid.verified.txt b/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid.verified.txt new file mode 100644 index 0000000..7e14e7a --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid.verified.txt @@ -0,0 +1,4 @@ +Options + -h, --help Show command line help. + -c, --configuration The configuration to run for. + The default for most projects is Debug. diff --git a/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid_Column_Alignment_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid_Column_Alignment_Correctly.verified.txt new file mode 100644 index 0000000..3f86f13 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid_Column_Alignment_Correctly.verified.txt @@ -0,0 +1,3 @@ + Foo Bar Baz + Qux Corgi Waldo +Grault Garply Fred diff --git a/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid_Correctly.verified.txt new file mode 100644 index 0000000..22e6688 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/GridTests.Should_Render_Grid_Correctly.verified.txt @@ -0,0 +1,2 @@ +Qux Corgi Waldo +Grault Garply Fred diff --git a/src/Spectre.Console.Tests/Unit/GridTests.Should_Use_Default_Padding.verified.txt b/src/Spectre.Console.Tests/Unit/GridTests.Should_Use_Default_Padding.verified.txt new file mode 100644 index 0000000..0ce90d4 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/GridTests.Should_Use_Default_Padding.verified.txt @@ -0,0 +1,3 @@ +Foo Bar Baz +Qux Corgi Waldo +Grault Garply Fred diff --git a/src/Spectre.Console.Tests/Unit/GridTests.TheAddEmptyRowMethod.Should_Add_Empty_Row.verified.txt b/src/Spectre.Console.Tests/Unit/GridTests.TheAddEmptyRowMethod.Should_Add_Empty_Row.verified.txt new file mode 100644 index 0000000..cc402c2 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/GridTests.TheAddEmptyRowMethod.Should_Add_Empty_Row.verified.txt @@ -0,0 +1,3 @@ +Foo Bar + +Qux Corgi diff --git a/src/Spectre.Console.Tests/Unit/GridTests.TheAddEmptyRowMethod.Should_Add_Empty_Row_At_The_End.verified.txt b/src/Spectre.Console.Tests/Unit/GridTests.TheAddEmptyRowMethod.Should_Add_Empty_Row_At_The_End.verified.txt new file mode 100644 index 0000000..17afbec --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/GridTests.TheAddEmptyRowMethod.Should_Add_Empty_Row_At_The_End.verified.txt @@ -0,0 +1,4 @@ +Foo Bar + +Qux Corgi + diff --git a/src/Spectre.Console.Tests/Unit/GridTests.cs b/src/Spectre.Console.Tests/Unit/GridTests.cs index 9e06035..afd43a6 100644 --- a/src/Spectre.Console.Tests/Unit/GridTests.cs +++ b/src/Spectre.Console.Tests/Unit/GridTests.cs @@ -1,9 +1,12 @@ using System; +using System.Threading.Tasks; using Shouldly; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class GridTests { public sealed class TheAddColumnMethod @@ -72,10 +75,11 @@ namespace Spectre.Console.Tests.Unit } } + [UsesVerify] public sealed class TheAddEmptyRowMethod { [Fact] - public void Should_Add_Empty_Row() + public Task Should_Add_Empty_Row() { // Given var console = new PlainConsole(width: 80); @@ -89,14 +93,11 @@ namespace Spectre.Console.Tests.Unit console.Render(grid); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("Foo Bar "); - console.Lines[1].ShouldBe(" "); - console.Lines[2].ShouldBe("Qux Corgi"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Add_Empty_Row_At_The_End() + public Task Should_Add_Empty_Row_At_The_End() { // Given var console = new PlainConsole(width: 80); @@ -111,16 +112,12 @@ namespace Spectre.Console.Tests.Unit console.Render(grid); // Then - console.Lines.Count.ShouldBe(4); - console.Lines[0].ShouldBe("Foo Bar "); - console.Lines[1].ShouldBe(" "); - console.Lines[2].ShouldBe("Qux Corgi"); - console.Lines[3].ShouldBe(" "); + return Verifier.Verify(console.Output); } } [Fact] - public void Should_Render_Grid_Correctly() + public Task Should_Render_Grid_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -135,13 +132,11 @@ namespace Spectre.Console.Tests.Unit console.Render(grid); // Then - console.Lines.Count.ShouldBe(2); - console.Lines[0].ShouldBe("Qux Corgi Waldo"); - console.Lines[1].ShouldBe("Grault Garply Fred "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Grid_Column_Alignment_Correctly() + public Task Should_Render_Grid_Column_Alignment_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -157,14 +152,11 @@ namespace Spectre.Console.Tests.Unit console.Render(grid); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe(" Foo Bar Baz "); - console.Lines[1].ShouldBe(" Qux Corgi Waldo"); - console.Lines[2].ShouldBe("Grault Garply Fred "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Use_Default_Padding() + public Task Should_Use_Default_Padding() { // Given var console = new PlainConsole(width: 80); @@ -178,14 +170,11 @@ namespace Spectre.Console.Tests.Unit console.Render(grid); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("Foo Bar Baz "); - console.Lines[1].ShouldBe("Qux Corgi Waldo"); - console.Lines[2].ShouldBe("Grault Garply Fred "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Explicit_Grid_Column_Padding_Correctly() + public Task Should_Render_Explicit_Grid_Column_Padding_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -201,14 +190,11 @@ namespace Spectre.Console.Tests.Unit console.Render(grid); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe(" Foo Bar Baz "); - console.Lines[1].ShouldBe(" Qux Corgi Waldo "); - console.Lines[2].ShouldBe(" GraultGarplyFred "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Grid() + public Task Should_Render_Grid() { var console = new PlainConsole(width: 80); var grid = new Grid(); @@ -222,11 +208,7 @@ namespace Spectre.Console.Tests.Unit console.Render(grid); // Then - console.Lines.Count.ShouldBe(4); - console.Lines[0].ShouldBe("Options "); - console.Lines[1].ShouldBe(" -h, --help Show command line help. "); - console.Lines[2].ShouldBe(" -c, --configuration The configuration to run for. "); - console.Lines[3].ShouldBe(" The default for most projects is Debug."); + return Verifier.Verify(console.Output); } } } diff --git a/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Expanded_Padded_Object_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Expanded_Padded_Object_Correctly.verified.txt new file mode 100644 index 0000000..b143cf6 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Expanded_Padded_Object_Correctly.verified.txt @@ -0,0 +1,12 @@ + + + ┌───────┬───────┐ + │ Foo │ Bar │ + ├───────┼───────┤ + │ Baz │ Qux │ + │ Corgi │ Waldo │ + └───────┴───────┘ + + + + diff --git a/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Padded_Object_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Padded_Object_Correctly.verified.txt new file mode 100644 index 0000000..7e42680 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Padded_Object_Correctly.verified.txt @@ -0,0 +1,12 @@ + + + ┌───────┬───────┐ + │ Foo │ Bar │ + ├───────┼───────┤ + │ Baz │ Qux │ + │ Corgi │ Waldo │ + └───────┴───────┘ + + + + diff --git a/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Padded_Object_Correctly_When_Nested_Within_Other_Object.verified.txt b/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Padded_Object_Correctly_When_Nested_Within_Other_Object.verified.txt new file mode 100644 index 0000000..d782c40 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PadderTests.Should_Render_Padded_Object_Correctly_When_Nested_Within_Other_Object.verified.txt @@ -0,0 +1,16 @@ + + + ┌───────┬─────────────┐ + │ Foo │Bar │ + ├───────┼─────────────┤ + │ Baz │Qux │ + │ Corgi │ │ + │ │ ┌───────┐ │ + │ │ │ Waldo │ │ + │ │ └───────┘ │ + │ │ │ + └───────┴─────────────┘ + + + + diff --git a/src/Spectre.Console.Tests/Unit/PadderTests.cs b/src/Spectre.Console.Tests/Unit/PadderTests.cs index b413dcd..a732f9c 100644 --- a/src/Spectre.Console.Tests/Unit/PadderTests.cs +++ b/src/Spectre.Console.Tests/Unit/PadderTests.cs @@ -1,12 +1,14 @@ -using Shouldly; +using System.Threading.Tasks; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class PadderTests { [Fact] - public void Should_Render_Padded_Object_Correctly() + public Task Should_Render_Padded_Object_Correctly() { // Given var console = new PlainConsole(width: 60); @@ -20,23 +22,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Padder(table).Padding(1, 2, 3, 4)); // Then - console.Lines.Count.ShouldBe(12); - console.Lines[00].ShouldBe(" "); - console.Lines[01].ShouldBe(" "); - console.Lines[02].ShouldBe(" ┌───────┬───────┐ "); - console.Lines[03].ShouldBe(" │ Foo │ Bar │ "); - console.Lines[04].ShouldBe(" ├───────┼───────┤ "); - console.Lines[05].ShouldBe(" │ Baz │ Qux │ "); - console.Lines[06].ShouldBe(" │ Corgi │ Waldo │ "); - console.Lines[07].ShouldBe(" └───────┴───────┘ "); - console.Lines[08].ShouldBe(" "); - console.Lines[09].ShouldBe(" "); - console.Lines[10].ShouldBe(" "); - console.Lines[11].ShouldBe(" "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Expanded_Padded_Object_Correctly() + public Task Should_Render_Expanded_Padded_Object_Correctly() { // Given var console = new PlainConsole(width: 60); @@ -52,23 +42,11 @@ namespace Spectre.Console.Tests.Unit .Expand()); // Then - console.Lines.Count.ShouldBe(12); - console.Lines[00].ShouldBe(" "); - console.Lines[01].ShouldBe(" "); - console.Lines[02].ShouldBe(" ┌───────┬───────┐ "); - console.Lines[03].ShouldBe(" │ Foo │ Bar │ "); - console.Lines[04].ShouldBe(" ├───────┼───────┤ "); - console.Lines[05].ShouldBe(" │ Baz │ Qux │ "); - console.Lines[06].ShouldBe(" │ Corgi │ Waldo │ "); - console.Lines[07].ShouldBe(" └───────┴───────┘ "); - console.Lines[08].ShouldBe(" "); - console.Lines[09].ShouldBe(" "); - console.Lines[10].ShouldBe(" "); - console.Lines[11].ShouldBe(" "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Padded_Object_Correctly_When_Nested_Within_Other_Object() + public Task Should_Render_Padded_Object_Correctly_When_Nested_Within_Other_Object() { // Given var console = new PlainConsole(width: 60); @@ -85,23 +63,7 @@ namespace Spectre.Console.Tests.Unit .Expand()); // Then - console.Lines.Count.ShouldBe(16); - console.Lines[00].ShouldBe(" "); - console.Lines[01].ShouldBe(" "); - console.Lines[02].ShouldBe(" ┌───────┬─────────────┐ "); - console.Lines[03].ShouldBe(" │ Foo │Bar │ "); - console.Lines[04].ShouldBe(" ├───────┼─────────────┤ "); - console.Lines[05].ShouldBe(" │ Baz │Qux │ "); - console.Lines[06].ShouldBe(" │ Corgi │ │ "); - console.Lines[07].ShouldBe(" │ │ ┌───────┐ │ "); - console.Lines[08].ShouldBe(" │ │ │ Waldo │ │ "); - console.Lines[09].ShouldBe(" │ │ └───────┘ │ "); - console.Lines[10].ShouldBe(" │ │ │ "); - console.Lines[11].ShouldBe(" └───────┴─────────────┘ "); - console.Lines[12].ShouldBe(" "); - console.Lines[13].ShouldBe(" "); - console.Lines[14].ShouldBe(" "); - console.Lines[15].ShouldBe(" "); + return Verifier.Verify(console.Output); } } } diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Center_Child_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Center_Child_Correctly.verified.txt new file mode 100644 index 0000000..d5f8622 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Center_Child_Correctly.verified.txt @@ -0,0 +1,3 @@ +┌───────────────────────┐ +│ Hello World │ +└───────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Collapse_Header_If_It_Will_Not_Fit.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Collapse_Header_If_It_Will_Not_Fit.verified.txt new file mode 100644 index 0000000..0779b31 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Collapse_Header_If_It_Will_Not_Fit.verified.txt @@ -0,0 +1,4 @@ +┌─Greet…─┐ +│ Hello │ +│ World │ +└────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Expand_Panel_If_Enabled.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Expand_Panel_If_Enabled.verified.txt new file mode 100644 index 0000000..cc19e88 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Expand_Panel_If_Enabled.verified.txt @@ -0,0 +1,3 @@ +┌──────────────────────────────────────────────────────────────────────────────┐ +│ Hello World │ +└──────────────────────────────────────────────────────────────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Justify_Child_To_Right_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Justify_Child_To_Right_Correctly.verified.txt new file mode 100644 index 0000000..e59d2ec --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Justify_Child_To_Right_Correctly.verified.txt @@ -0,0 +1,3 @@ +┌───────────────────────┐ +│ Hello World │ +└───────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Preserve_Explicit_Line_Ending.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Preserve_Explicit_Line_Ending.verified.txt new file mode 100644 index 0000000..cc53229 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Preserve_Explicit_Line_Ending.verified.txt @@ -0,0 +1,7 @@ +┌───────────────────────┐ +│ I heard you like 📦 │ +│ │ +│ │ +│ │ +│ So I put a 📦 in a 📦 │ +└───────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel.verified.txt new file mode 100644 index 0000000..00bba37 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel.verified.txt @@ -0,0 +1,3 @@ +┌─────────────┐ +│ Hello World │ +└─────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_Inside_Panel_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_Inside_Panel_Correctly.verified.txt new file mode 100644 index 0000000..66732dd --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_Inside_Panel_Correctly.verified.txt @@ -0,0 +1,5 @@ +┌─────────────────┐ +│ ┌─────────────┐ │ +│ │ Hello World │ │ +│ └─────────────┘ │ +└─────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Centered_Header.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Centered_Header.verified.txt new file mode 100644 index 0000000..2e28ea3 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Centered_Header.verified.txt @@ -0,0 +1,3 @@ +┌───────────────────────────────────Greeting───────────────────────────────────┐ +│ Hello World │ +└──────────────────────────────────────────────────────────────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Header.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Header.verified.txt new file mode 100644 index 0000000..bf19a92 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Header.verified.txt @@ -0,0 +1,3 @@ +┌─Greeting─────────────────────────────────────────────────────────────────────┐ +│ Hello World │ +└──────────────────────────────────────────────────────────────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Left_Aligned_Header.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Left_Aligned_Header.verified.txt new file mode 100644 index 0000000..9c48300 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Left_Aligned_Header.verified.txt @@ -0,0 +1,3 @@ +┌─Greeting─────────────────────────────────────────────────────────────────────┐ +│ Hello World │ +└──────────────────────────────────────────────────────────────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Multiple_Lines.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Multiple_Lines.verified.txt new file mode 100644 index 0000000..195af30 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Multiple_Lines.verified.txt @@ -0,0 +1,4 @@ +┌─────────────┐ +│ Hello World │ +│ Foo Bar │ +└─────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Padding.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Padding.verified.txt new file mode 100644 index 0000000..a90e8ca --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Padding.verified.txt @@ -0,0 +1,6 @@ +┌───────────────────┐ +│ │ +│ Hello World │ +│ │ +│ │ +└───────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Padding_Set_To_Zero.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Padding_Set_To_Zero.verified.txt new file mode 100644 index 0000000..8b9f309 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Padding_Set_To_Zero.verified.txt @@ -0,0 +1,3 @@ +┌───────────┐ +│Hello World│ +└───────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Right_Aligned_Header.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Right_Aligned_Header.verified.txt new file mode 100644 index 0000000..a6472f8 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Right_Aligned_Header.verified.txt @@ -0,0 +1,3 @@ +┌─────────────────────────────────────────────────────────────────────Greeting─┐ +│ Hello World │ +└──────────────────────────────────────────────────────────────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Unicode_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Unicode_Correctly.verified.txt new file mode 100644 index 0000000..4f3c720 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Render_Panel_With_Unicode_Correctly.verified.txt @@ -0,0 +1,5 @@ +┌────┐ +│ │ +│ 💩 │ +│ │ +└────┘ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.Should_Wrap_Content_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Wrap_Content_Correctly.verified.txt new file mode 100644 index 0000000..5b47ab5 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PanelTests.Should_Wrap_Content_Correctly.verified.txt @@ -0,0 +1,4 @@ +╭─Short paths──────────────────────────────────────────────────────────────────────╮ +│ at System.Runtime.CompilerServices.TaskAwaiter. │ +│ HandleNonSuccessAndDebuggerNotification(Task task) │ +╰──────────────────────────────────────────────────────────────────────────────────╯ diff --git a/src/Spectre.Console.Tests/Unit/PanelTests.cs b/src/Spectre.Console.Tests/Unit/PanelTests.cs index 1faa679..a32d052 100644 --- a/src/Spectre.Console.Tests/Unit/PanelTests.cs +++ b/src/Spectre.Console.Tests/Unit/PanelTests.cs @@ -1,14 +1,16 @@ using System.Collections.Generic; -using Shouldly; +using System.Threading.Tasks; using Spectre.Console.Rendering; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class PanelTests { [Fact] - public void Should_Render_Panel() + public Task Should_Render_Panel() { // Given var console = new PlainConsole(width: 80); @@ -17,14 +19,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Panel(new Text("Hello World"))); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌─────────────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└─────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_With_Padding_Set_To_Zero() + public Task Should_Render_Panel_With_Padding_Set_To_Zero() { // Given var console = new PlainConsole(width: 80); @@ -36,14 +35,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌───────────┐"); - console.Lines[1].ShouldBe("│Hello World│"); - console.Lines[2].ShouldBe("└───────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_With_Padding() + public Task Should_Render_Panel_With_Padding() { // Given var console = new PlainConsole(width: 80); @@ -55,17 +51,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(6); - console.Lines[0].ShouldBe("┌───────────────────┐"); - console.Lines[1].ShouldBe("│ │"); - console.Lines[2].ShouldBe("│ Hello World │"); - console.Lines[3].ShouldBe("│ │"); - console.Lines[4].ShouldBe("│ │"); - console.Lines[5].ShouldBe("└───────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_With_Header() + public Task Should_Render_Panel_With_Header() { // Given var console = new PlainConsole(width: 80); @@ -79,14 +69,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌─Greeting─────────────────────────────────────────────────────────────────────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└──────────────────────────────────────────────────────────────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_With_Left_Aligned_Header() + public Task Should_Render_Panel_With_Left_Aligned_Header() { // Given var console = new PlainConsole(width: 80); @@ -99,14 +86,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌─Greeting─────────────────────────────────────────────────────────────────────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└──────────────────────────────────────────────────────────────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_With_Centered_Header() + public Task Should_Render_Panel_With_Centered_Header() { // Given var console = new PlainConsole(width: 80); @@ -119,14 +103,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌───────────────────────────────────Greeting───────────────────────────────────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└──────────────────────────────────────────────────────────────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_With_Right_Aligned_Header() + public Task Should_Render_Panel_With_Right_Aligned_Header() { // Given var console = new PlainConsole(width: 80); @@ -139,14 +120,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌─────────────────────────────────────────────────────────────────────Greeting─┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└──────────────────────────────────────────────────────────────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Collapse_Header_If_It_Will_Not_Fit() + public Task Should_Collapse_Header_If_It_Will_Not_Fit() { // Given var console = new PlainConsole(width: 10); @@ -159,15 +137,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(4); - console.Lines[0].ShouldBe("┌─Greet…─┐"); - console.Lines[1].ShouldBe("│ Hello │"); - console.Lines[2].ShouldBe("│ World │"); - console.Lines[3].ShouldBe("└────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_With_Unicode_Correctly() + public Task Should_Render_Panel_With_Unicode_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -176,16 +150,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Panel(new Text(" \n💩\n "))); // Then - console.Lines.Count.ShouldBe(5); - console.Lines[0].ShouldBe("┌────┐"); - console.Lines[1].ShouldBe("│ │"); - console.Lines[2].ShouldBe("│ 💩 │"); - console.Lines[3].ShouldBe("│ │"); - console.Lines[4].ShouldBe("└────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_With_Multiple_Lines() + public Task Should_Render_Panel_With_Multiple_Lines() { // Given var console = new PlainConsole(width: 80); @@ -194,15 +163,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Panel(new Text("Hello World\nFoo Bar"))); // Then - console.Lines.Count.ShouldBe(4); - console.Lines[0].ShouldBe("┌─────────────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("│ Foo Bar │"); - console.Lines[3].ShouldBe("└─────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Preserve_Explicit_Line_Ending() + public Task Should_Preserve_Explicit_Line_Ending() { // Given var console = new PlainConsole(width: 80); @@ -213,18 +178,11 @@ namespace Spectre.Console.Tests.Unit console.Render(text); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe("┌───────────────────────┐"); - console.Lines[1].ShouldBe("│ I heard you like 📦 │"); - console.Lines[2].ShouldBe("│ │"); - console.Lines[3].ShouldBe("│ │"); - console.Lines[4].ShouldBe("│ │"); - console.Lines[5].ShouldBe("│ So I put a 📦 in a 📦 │"); - console.Lines[6].ShouldBe("└───────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Expand_Panel_If_Enabled() + public Task Should_Expand_Panel_If_Enabled() { // Given var console = new PlainConsole(width: 80); @@ -236,15 +194,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].Length.ShouldBe(80); - console.Lines[0].ShouldBe("┌──────────────────────────────────────────────────────────────────────────────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└──────────────────────────────────────────────────────────────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Justify_Child_To_Right_Correctly() + public Task Should_Justify_Child_To_Right_Correctly() { // Given var console = new PlainConsole(width: 25); @@ -257,14 +211,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌───────────────────────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└───────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Center_Child_Correctly() + public Task Should_Center_Child_Correctly() { // Given var console = new PlainConsole(width: 25); @@ -277,14 +228,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌───────────────────────┐"); - console.Lines[1].ShouldBe("│ Hello World │"); - console.Lines[2].ShouldBe("└───────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Panel_Inside_Panel_Correctly() + public Task Should_Render_Panel_Inside_Panel_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -293,16 +241,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Panel(new Panel(new Text("Hello World")))); // Then - console.Lines.Count.ShouldBe(5); - console.Lines[0].ShouldBe("┌─────────────────┐"); - console.Lines[1].ShouldBe("│ ┌─────────────┐ │"); - console.Lines[2].ShouldBe("│ │ Hello World │ │"); - console.Lines[3].ShouldBe("│ └─────────────┘ │"); - console.Lines[4].ShouldBe("└─────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Wrap_Content_Correctly() + public Task Should_Wrap_Content_Correctly() { // Given var console = new PlainConsole(width: 84); @@ -322,11 +265,7 @@ namespace Spectre.Console.Tests.Unit console.Render(panel); // Then - console.Lines.Count.ShouldBe(4); - console.Lines[0].ShouldBe("╭─Short paths──────────────────────────────────────────────────────────────────────╮"); - console.Lines[1].ShouldBe("│ at System.Runtime.CompilerServices.TaskAwaiter. │"); - console.Lines[2].ShouldBe("│ HandleNonSuccessAndDebuggerNotification(Task task) │"); - console.Lines[3].ShouldBe("╰──────────────────────────────────────────────────────────────────────────────────╯"); + return Verifier.Verify(console.Output); } } } diff --git a/src/Spectre.Console.Tests/Unit/PromptTests.Should_Accept_Choice_In_List.verified.txt b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Accept_Choice_In_List.verified.txt new file mode 100644 index 0000000..06d191a --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Accept_Choice_In_List.verified.txt @@ -0,0 +1 @@ +Favorite fruit? [Banana/Orange] (Banana): Orange diff --git a/src/Spectre.Console.Tests/Unit/PromptTests.Should_Chose_Default_Value_If_Nothing_Is_Entered.verified.txt b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Chose_Default_Value_If_Nothing_Is_Entered.verified.txt new file mode 100644 index 0000000..675f10f --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Chose_Default_Value_If_Nothing_Is_Entered.verified.txt @@ -0,0 +1 @@ +Favorite fruit? [Banana/Orange] (Banana): Banana diff --git a/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Error_If_An_Invalid_Choice_Is_Made.verified.txt b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Error_If_An_Invalid_Choice_Is_Made.verified.txt new file mode 100644 index 0000000..b4040d4 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Error_If_An_Invalid_Choice_Is_Made.verified.txt @@ -0,0 +1,3 @@ +Favorite fruit? [Banana/Orange] (Banana): Apple +Please select one of the available options +Favorite fruit? [Banana/Orange] (Banana): Banana diff --git a/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Error_If_Custom_Validation_Fails.verified.txt b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Error_If_Custom_Validation_Fails.verified.txt new file mode 100644 index 0000000..02f67b3 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Error_If_Custom_Validation_Fails.verified.txt @@ -0,0 +1,7 @@ +Guess number: 22 +Too low +Guess number: 102 +Too high +Guess number: ABC +Invalid input +Guess number: 99 diff --git a/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Validation_Error_If_Value_Cannot_Be_Converted.verified.txt b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Validation_Error_If_Value_Cannot_Be_Converted.verified.txt new file mode 100644 index 0000000..ee81eb7 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/PromptTests.Should_Return_Validation_Error_If_Value_Cannot_Be_Converted.verified.txt @@ -0,0 +1,5 @@ +[ + Age? ninety-nine, + Invalid input, + Age? 99 +] \ No newline at end of file diff --git a/src/Spectre.Console.Tests/Unit/PromptTests.cs b/src/Spectre.Console.Tests/Unit/PromptTests.cs index 4fe05f1..4a5ec8f 100644 --- a/src/Spectre.Console.Tests/Unit/PromptTests.cs +++ b/src/Spectre.Console.Tests/Unit/PromptTests.cs @@ -1,13 +1,15 @@ using System; -using Shouldly; +using System.Threading.Tasks; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class PromptTests { [Fact] - public void Should_Return_Validation_Error_If_Value_Cannot_Be_Converted() + public Task Should_Return_Validation_Error_If_Value_Cannot_Be_Converted() { // Given var console = new PlainConsole(); @@ -18,14 +20,11 @@ namespace Spectre.Console.Tests.Unit console.Prompt(new TextPrompt("Age?")); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("Age? ninety-nine"); - console.Lines[1].ShouldBe("Invalid input"); - console.Lines[2].ShouldBe("Age? 99"); + return Verifier.Verify(console.Lines); } [Fact] - public void Should_Chose_Default_Value_If_Nothing_Is_Entered() + public Task Should_Chose_Default_Value_If_Nothing_Is_Entered() { // Given var console = new PlainConsole(); @@ -39,12 +38,11 @@ namespace Spectre.Console.Tests.Unit .DefaultValue("Banana")); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("Favorite fruit? [Banana/Orange] (Banana): Banana"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Return_Error_If_An_Invalid_Choice_Is_Made() + public Task Should_Return_Error_If_An_Invalid_Choice_Is_Made() { // Given var console = new PlainConsole(); @@ -59,14 +57,11 @@ namespace Spectre.Console.Tests.Unit .DefaultValue("Banana")); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("Favorite fruit? [Banana/Orange] (Banana): Apple"); - console.Lines[1].ShouldBe("Please select one of the available options"); - console.Lines[2].ShouldBe("Favorite fruit? [Banana/Orange] (Banana): Banana"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Accept_Choice_In_List() + public Task Should_Accept_Choice_In_List() { // Given var console = new PlainConsole(); @@ -80,12 +75,11 @@ namespace Spectre.Console.Tests.Unit .DefaultValue("Banana")); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("Favorite fruit? [Banana/Orange] (Banana): Orange"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Return_Error_If_Custom_Validation_Fails() + public Task Should_Return_Error_If_Custom_Validation_Fails() { // Given var console = new PlainConsole(); @@ -113,14 +107,7 @@ namespace Spectre.Console.Tests.Unit })); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe("Guess number: 22"); - console.Lines[1].ShouldBe("Too low"); - console.Lines[2].ShouldBe("Guess number: 102"); - console.Lines[3].ShouldBe("Too high"); - console.Lines[4].ShouldBe("Guess number: ABC"); - console.Lines[5].ShouldBe("Invalid input"); - console.Lines[6].ShouldBe("Guess number: 99"); + return Verifier.Verify(console.Output); } } } diff --git a/src/Spectre.Console.Tests/Unit/RecorderTests.Should_Export_Html_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/RecorderTests.Should_Export_Html_As_Expected.verified.txt new file mode 100644 index 0000000..5e20bc3 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RecorderTests.Should_Export_Html_As_Expected.verified.txt @@ -0,0 +1,10 @@ +
+┌─────────────────┬───────┬─────┐
+FooBarQux
+├─────────────────┼───────┼─────┤
+CorgiWaldoZap
+╭─────────────╮ │       │     │
+ Hello World  │       │     │
+╰─────────────╯ │       │     │
+└─────────────────┴───────┴─────┘
+
\ No newline at end of file diff --git a/src/Spectre.Console.Tests/Unit/RecorderTests.Should_Export_Text_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/RecorderTests.Should_Export_Text_As_Expected.verified.txt new file mode 100644 index 0000000..d4e2fff --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RecorderTests.Should_Export_Text_As_Expected.verified.txt @@ -0,0 +1,8 @@ +┌─────────────────┬───────┬─────┐ +│ Foo │ Bar │ Qux │ +├─────────────────┼───────┼─────┤ +│ Corgi │ Waldo │ Zap │ +│ ╭─────────────╮ │ │ │ +│ │ Hello World │ │ │ │ +│ ╰─────────────╯ │ │ │ +└─────────────────┴───────┴─────┘ \ No newline at end of file diff --git a/src/Spectre.Console.Tests/Unit/RecorderTests.cs b/src/Spectre.Console.Tests/Unit/RecorderTests.cs index 96cfd0c..4b4715c 100644 --- a/src/Spectre.Console.Tests/Unit/RecorderTests.cs +++ b/src/Spectre.Console.Tests/Unit/RecorderTests.cs @@ -1,12 +1,14 @@ -using Shouldly; +using System.Threading.Tasks; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class RecorderTests { [Fact] - public void Should_Export_Text_As_Expected() + public Task Should_Export_Text_As_Expected() { // Given var console = new PlainConsole(); @@ -18,22 +20,14 @@ namespace Spectre.Console.Tests.Unit .AddRow(new Panel("Hello World").RoundedBorder())); // When - var result = recorder.ExportText().Split(new[] { '\n' }); + var result = recorder.ExportText(); // Then - result.Length.ShouldBe(8); - result[0].ShouldBe("┌─────────────────┬───────┬─────┐"); - result[1].ShouldBe("│ Foo │ Bar │ Qux │"); - result[2].ShouldBe("├─────────────────┼───────┼─────┤"); - result[3].ShouldBe("│ Corgi │ Waldo │ Zap │"); - result[4].ShouldBe("│ ╭─────────────╮ │ │ │"); - result[5].ShouldBe("│ │ Hello World │ │ │ │"); - result[6].ShouldBe("│ ╰─────────────╯ │ │ │"); - result[7].ShouldBe("└─────────────────┴───────┴─────┘"); + return Verifier.Verify(result); } [Fact] - public void Should_Export_Html_As_Expected() + public Task Should_Export_Html_As_Expected() { // Given var console = new PlainConsole(); @@ -46,21 +40,10 @@ namespace Spectre.Console.Tests.Unit .BorderColor(Color.Red).RoundedBorder())); // When - var html = recorder.ExportHtml(); - var result = html.Split(new[] { '\n' }); + var result = recorder.ExportHtml(); // Then - result.Length.ShouldBe(10); - result[0].ShouldBe("
");
-            result[1].ShouldBe("┌─────────────────┬───────┬─────┐");
-            result[2].ShouldBe("FooBarQux");
-            result[3].ShouldBe("├─────────────────┼───────┼─────┤");
-            result[4].ShouldBe("CorgiWaldoZap");
-            result[5].ShouldBe("╭─────────────╮ │       │     │");
-            result[6].ShouldBe(" Hello World  │       │     │");
-            result[7].ShouldBe("╰─────────────╯ │       │     │");
-            result[8].ShouldBe("└─────────────────┴───────┴─────┘");
-            result[9].ShouldBe("
"); + return Verifier.Verify(result); } } } diff --git a/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows.verified.txt b/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows.verified.txt new file mode 100644 index 0000000..f8bc206 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows.verified.txt @@ -0,0 +1,7 @@ +Hello +┌─────┬─────┐ +│ Foo │ Bar │ +├─────┼─────┤ +│ Baz │ Qux │ +└─────┴─────┘ +World diff --git a/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows_Correctly_Inside_Other_Widget.verified.txt b/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows_Correctly_Inside_Other_Widget.verified.txt new file mode 100644 index 0000000..d17b85c --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows_Correctly_Inside_Other_Widget.verified.txt @@ -0,0 +1,7 @@ +┌─────────────┬─────┐ +│ Foo │ Bar │ +├─────────────┼─────┤ +│ HELLO WORLD │ │ +│ Hello │ Qux │ +│ World │ │ +└─────────────┴─────┘ diff --git a/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows_Correctly_Inside_Other_Widget_When_Expanded.verified.txt b/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows_Correctly_Inside_Other_Widget_When_Expanded.verified.txt new file mode 100644 index 0000000..ff66761 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RowsTests.Should_Render_Rows_Correctly_Inside_Other_Widget_When_Expanded.verified.txt @@ -0,0 +1,7 @@ +┌────────────────────────────────────────────────────┬─────┐ +│ Foo │ Bar │ +├────────────────────────────────────────────────────┼─────┤ +│ HELLO WORLD │ │ +│ Hello │ Qux │ +│ World │ │ +└────────────────────────────────────────────────────┴─────┘ diff --git a/src/Spectre.Console.Tests/Unit/RowsTests.cs b/src/Spectre.Console.Tests/Unit/RowsTests.cs index 3b57a12..61cdf41 100644 --- a/src/Spectre.Console.Tests/Unit/RowsTests.cs +++ b/src/Spectre.Console.Tests/Unit/RowsTests.cs @@ -1,13 +1,15 @@ -using Shouldly; +using System.Threading.Tasks; using Spectre.Console.Rendering; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class RowsTests { [Fact] - public void Should_Render_Rows() + public Task Should_Render_Rows() { // Given var console = new PlainConsole(width: 60); @@ -25,18 +27,11 @@ namespace Spectre.Console.Tests.Unit console.Render(rows); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe("Hello"); - console.Lines[1].ShouldBe("┌─────┬─────┐"); - console.Lines[2].ShouldBe("│ Foo │ Bar │"); - console.Lines[3].ShouldBe("├─────┼─────┤"); - console.Lines[4].ShouldBe("│ Baz │ Qux │"); - console.Lines[5].ShouldBe("└─────┴─────┘"); - console.Lines[6].ShouldBe("World"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Rows_Correctly_Inside_Other_Widget() + public Task Should_Render_Rows_Correctly_Inside_Other_Widget() { // Given var console = new PlainConsole(width: 60); @@ -54,18 +49,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe("┌─────────────┬─────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │"); - console.Lines[2].ShouldBe("├─────────────┼─────┤"); - console.Lines[3].ShouldBe("│ HELLO WORLD │ │"); - console.Lines[4].ShouldBe("│ Hello │ Qux │"); - console.Lines[5].ShouldBe("│ World │ │"); - console.Lines[6].ShouldBe("└─────────────┴─────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Rows_Correctly_Inside_Other_Widget_When_Expanded() + public Task Should_Render_Rows_Correctly_Inside_Other_Widget_When_Expanded() { // Given var console = new PlainConsole(width: 60); @@ -83,14 +71,7 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe("┌────────────────────────────────────────────────────┬─────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │"); - console.Lines[2].ShouldBe("├────────────────────────────────────────────────────┼─────┤"); - console.Lines[3].ShouldBe("│ HELLO WORLD │ │"); - console.Lines[4].ShouldBe("│ Hello │ Qux │"); - console.Lines[5].ShouldBe("│ World │ │"); - console.Lines[6].ShouldBe("└────────────────────────────────────────────────────┴─────┘"); + return Verifier.Verify(console.Output); } } } diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.Should_Convert_Line_Breaks_In_Title_To_Spaces.verified.txt b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Convert_Line_Breaks_In_Title_To_Spaces.verified.txt new file mode 100644 index 0000000..e5bdadd --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Convert_Line_Breaks_In_Title_To_Spaces.verified.txt @@ -0,0 +1 @@ +──────────── Hello World ! ───────────── diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Specified_Box.verified.txt b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Specified_Box.verified.txt new file mode 100644 index 0000000..cd15005 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Specified_Box.verified.txt @@ -0,0 +1 @@ +════════════════════════════════════════ diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Centered_By_Default.verified.txt b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Centered_By_Default.verified.txt new file mode 100644 index 0000000..5e2f41d --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Centered_By_Default.verified.txt @@ -0,0 +1 @@ +───────────── Hello World ────────────── diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Left_Aligned.verified.txt b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Left_Aligned.verified.txt new file mode 100644 index 0000000..33602ea --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Left_Aligned.verified.txt @@ -0,0 +1 @@ +── Hello World ───────────────────────── diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Right_Aligned.verified.txt b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Right_Aligned.verified.txt new file mode 100644 index 0000000..f1ae559 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_With_Title_Right_Aligned.verified.txt @@ -0,0 +1 @@ +───────────────────────── Hello World ── diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_Without_Title.verified.txt b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_Without_Title.verified.txt new file mode 100644 index 0000000..34f1021 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_Default_Rule_Without_Title.verified.txt @@ -0,0 +1 @@ +──────────────────────────────────────── diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_With_Specified_Box.verified.txt b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_With_Specified_Box.verified.txt new file mode 100644 index 0000000..dc02bb7 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Render_With_Specified_Box.verified.txt @@ -0,0 +1 @@ +═════════════ Hello World ══════════════ diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.Should_Truncate_Title.verified.txt b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Truncate_Title.verified.txt new file mode 100644 index 0000000..5e2f41d --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/RuleTests.Should_Truncate_Title.verified.txt @@ -0,0 +1 @@ +───────────── Hello World ────────────── diff --git a/src/Spectre.Console.Tests/Unit/RuleTests.cs b/src/Spectre.Console.Tests/Unit/RuleTests.cs index a39113b..1289a7a 100644 --- a/src/Spectre.Console.Tests/Unit/RuleTests.cs +++ b/src/Spectre.Console.Tests/Unit/RuleTests.cs @@ -1,12 +1,15 @@ +using System.Threading.Tasks; using Shouldly; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class RuleTests { [Fact] - public void Should_Render_Default_Rule_Without_Title() + public Task Should_Render_Default_Rule_Without_Title() { // Given var console = new PlainConsole(width: 40); @@ -15,12 +18,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Rule()); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("────────────────────────────────────────"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Default_Rule_With_Specified_Box() + public Task Should_Render_Default_Rule_With_Specified_Box() { // Given var console = new PlainConsole(width: 40); @@ -29,12 +31,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Rule().DoubleBorder()); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("════════════════════════════════════════"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_With_Specified_Box() + public Task Should_Render_With_Specified_Box() { // Given var console = new PlainConsole(width: 40); @@ -43,12 +44,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Rule("Hello World").DoubleBorder()); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("═════════════ Hello World ══════════════"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Default_Rule_With_Title_Centered_By_Default() + public Task Should_Render_Default_Rule_With_Title_Centered_By_Default() { // Given var console = new PlainConsole(width: 40); @@ -57,12 +57,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Rule("Hello World")); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("───────────── Hello World ──────────────"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Default_Rule_With_Title_Left_Aligned() + public Task Should_Render_Default_Rule_With_Title_Left_Aligned() { // Given var console = new PlainConsole(width: 40); @@ -74,12 +73,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("── Hello World ─────────────────────────"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Default_Rule_With_Title_Right_Aligned() + public Task Should_Render_Default_Rule_With_Title_Right_Aligned() { // Given var console = new PlainConsole(width: 40); @@ -91,12 +89,11 @@ namespace Spectre.Console.Tests.Unit }); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("───────────────────────── Hello World ──"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Convert_Line_Breaks_In_Title_To_Spaces() + public Task Should_Convert_Line_Breaks_In_Title_To_Spaces() { // Given var console = new PlainConsole(width: 40); @@ -105,12 +102,11 @@ namespace Spectre.Console.Tests.Unit console.Render(new Rule("Hello\nWorld\r\n!")); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("──────────── Hello World ! ─────────────"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Truncate_Title() + public Task Should_Truncate_Title() { // Given var console = new PlainConsole(width: 40); @@ -119,8 +115,7 @@ namespace Spectre.Console.Tests.Unit console.Render(new Rule(" Hello World ")); // Then - console.Lines.Count.ShouldBe(1); - console.Lines[0].ShouldBe("───────────── Hello World ──────────────"); + return Verifier.Verify(console.Output); } [Theory] diff --git a/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitLinesMethod.Should_Split_Segment.verified.txt b/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitLinesMethod.Should_Split_Segment.verified.txt new file mode 100644 index 0000000..7fb65eb --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitLinesMethod.Should_Split_Segment.verified.txt @@ -0,0 +1,43 @@ +[ + [ + { + Text: Foo, + Style: { + Foreground: {}, + Background: {} + } + }, + { + Text: Bar, + Style: { + Foreground: {}, + Background: {} + } + } + ], + [ + { + Text: Baz, + Style: { + Foreground: {}, + Background: {} + } + }, + { + Text: Qux, + Style: { + Foreground: {}, + Background: {} + } + } + ], + [ + { + Text: Corgi, + Style: { + Foreground: {}, + Background: {} + } + } + ] +] \ No newline at end of file diff --git a/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitLinesMethod.Should_Split_Segments_With_Linebreak_In_Text.verified.txt b/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitLinesMethod.Should_Split_Segments_With_Linebreak_In_Text.verified.txt new file mode 100644 index 0000000..626d3e6 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitLinesMethod.Should_Split_Segments_With_Linebreak_In_Text.verified.txt @@ -0,0 +1,45 @@ +[ + [ + { + Text: Foo, + Style: { + Foreground: {}, + Background: {} + } + } + ], + [ + { + Text: Bar, + Style: { + Foreground: {}, + Background: {} + } + } + ], + [ + { + Text: Baz, + Style: { + Foreground: {}, + Background: {} + } + }, + { + Text: Qux, + Style: { + Foreground: {}, + Background: {} + } + } + ], + [ + { + Text: Corgi, + Style: { + Foreground: {}, + Background: {} + } + } + ] +] \ No newline at end of file diff --git a/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitMethod.Should_Split_Segment_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitMethod.Should_Split_Segment_Correctly.verified.txt new file mode 100644 index 0000000..c166de8 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/SegmentTests.TheSplitMethod.Should_Split_Segment_Correctly.verified.txt @@ -0,0 +1,26 @@ +{ + Item1: { + Text: Foo, + Style: { + Foreground: { + R: 255 + }, + Background: { + G: 128 + }, + Decoration: Bold + } + }, + Item2: { + Text: Bar, + Style: { + Foreground: { + R: 255 + }, + Background: { + G: 128 + }, + Decoration: Bold + } + } +} \ No newline at end of file diff --git a/src/Spectre.Console.Tests/Unit/SegmentTests.cs b/src/Spectre.Console.Tests/Unit/SegmentTests.cs index f3cf5f9..5177747 100644 --- a/src/Spectre.Console.Tests/Unit/SegmentTests.cs +++ b/src/Spectre.Console.Tests/Unit/SegmentTests.cs @@ -1,6 +1,8 @@ using System.Text; +using System.Threading.Tasks; using Shouldly; using Spectre.Console.Rendering; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit @@ -17,30 +19,29 @@ namespace Spectre.Console.Tests.Unit result.ShouldBe(4); } + [UsesVerify] public sealed class TheSplitMethod { [Fact] - public void Should_Split_Segment_Correctly() + public Task Should_Split_Segment_Correctly() { // Given var style = new Style(Color.Red, Color.Green, Decoration.Bold); var segment = new Segment("Foo Bar", style); // When - var (first, second) = segment.Split(3); + var result = segment.Split(3); // Then - first.Text.ShouldBe("Foo"); - first.Style.ShouldBe(style); - second.Text.ShouldBe(" Bar"); - second.Style.ShouldBe(style); + return Verifier.Verify(result); } } + [UsesVerify] public sealed class TheSplitLinesMethod { [Fact] - public void Should_Split_Segment() + public Task Should_Split_Segment() { var context = new RenderContext(Encoding.UTF8, false); @@ -70,10 +71,11 @@ namespace Spectre.Console.Tests.Unit lines[2].Count.ShouldBe(1); lines[2][0].Text.ShouldBe("Corgi"); + return Verifier.Verify(lines); } [Fact] - public void Should_Split_Segments_With_Linebreak_In_Text() + public Task Should_Split_Segments_With_Linebreak_In_Text() { var context = new RenderContext(Encoding.UTF8, false); var lines = Segment.SplitLines( @@ -88,20 +90,7 @@ namespace Spectre.Console.Tests.Unit }); // Then - lines.Count.ShouldBe(4); - - lines[0].Count.ShouldBe(1); - lines[0][0].Text.ShouldBe("Foo"); - - lines[1].Count.ShouldBe(1); - lines[1][0].Text.ShouldBe("Bar"); - - lines[2].Count.ShouldBe(2); - lines[2][0].Text.ShouldBe("Baz"); - lines[2][1].Text.ShouldBe("Qux"); - - lines[3].Count.ShouldBe(1); - lines[3][0].Text.ShouldBe("Corgi"); + return Verifier.Verify(lines); } } } diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.Ascii2Border.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.Ascii2Border.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..8ecf0b0 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.Ascii2Border.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ ++----------+----------+ +| Header 1 | Header 2 | +|----------+----------| +| Cell | Cell | +| Cell | Cell | +|----------+----------| +| Footer 1 | Footer 2 | ++----------+----------+ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.AsciiBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.AsciiBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..f8c4bac --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.AsciiBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ ++---------------------+ +| Header 1 | Header 2 | +|----------+----------| +| Cell | Cell | +| Cell | Cell | +|----------+----------| +| Footer 1 | Footer 2 | ++---------------------+ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.AsciiDoubleHeadBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.AsciiDoubleHeadBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..4c681e4 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.AsciiDoubleHeadBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ ++----------+----------+ +| Header 1 | Header 2 | +|==========+==========| +| Cell | Cell | +| Cell | Cell | ++----------+----------+ +| Footer 1 | Footer 2 | ++----------+----------+ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.DoubleBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.DoubleBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..89cee53 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.DoubleBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ +╔══════════╦══════════╗ +║ Header 1 ║ Header 2 ║ +╠══════════╬══════════╣ +║ Cell ║ Cell ║ +║ Cell ║ Cell ║ +╠══════════╬══════════╣ +║ Footer 1 ║ Footer 2 ║ +╚══════════╩══════════╝ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.DoubleEdgeBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.DoubleEdgeBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..6d72748 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.DoubleEdgeBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ +╔══════════╤══════════╗ +║ Header 1 │ Header 2 ║ +╟──────────┼──────────╢ +║ Cell │ Cell ║ +║ Cell │ Cell ║ +╟──────────┼──────────╢ +║ Footer 1 │ Footer 2 ║ +╚══════════╧══════════╝ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..7f71471 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ +┏━━━━━━━━━━┳━━━━━━━━━━┓ +┃ Header 1 ┃ Header 2 ┃ +┣━━━━━━━━━━╋━━━━━━━━━━┫ +┃ Cell ┃ Cell ┃ +┃ Cell ┃ Cell ┃ +┣━━━━━━━━━━╋━━━━━━━━━━┫ +┃ Footer 1 ┃ Footer 2 ┃ +┗━━━━━━━━━━┻━━━━━━━━━━┛ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyEdgeBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyEdgeBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..380a850 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyEdgeBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ +┏━━━━━━━━━━┯━━━━━━━━━━┓ +┃ Header 1 │ Header 2 ┃ +┠──────────┼──────────┨ +┃ Cell │ Cell ┃ +┃ Cell │ Cell ┃ +┠──────────┼──────────┨ +┃ Footer 1 │ Footer 2 ┃ +┗━━━━━━━━━━┷━━━━━━━━━━┛ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyHeadBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyHeadBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..52ed281 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.HeavyHeadBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ +┏━━━━━━━━━━┳━━━━━━━━━━┓ +┃ Header 1 ┃ Header 2 ┃ +┡━━━━━━━━━━╇━━━━━━━━━━┩ +│ Cell │ Cell │ +│ Cell │ Cell │ +├──────────┼──────────┤ +│ Footer 1 │ Footer 2 │ +└──────────┴──────────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.HorizontalBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.HorizontalBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..7483d9e --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.HorizontalBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ +─────────────────────── + Header 1 Header 2 +─────────────────────── + Cell Cell + Cell Cell +─────────────────────── + Footer 1 Footer 2 +─────────────────────── diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..f76a93c --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,7 @@ + +| Header 1 | Header 2 | +| -------- | -------- | +| Cell | Cell | +| Cell | Cell | +| Footer 1 | Footer 2 | + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Center_Aligned_Table_Columns_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Center_Aligned_Table_Columns_As_Expected.verified.txt new file mode 100644 index 0000000..baf9537 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Center_Aligned_Table_Columns_As_Expected.verified.txt @@ -0,0 +1,7 @@ + +| Header 1 | Header 2 | +| -------- | :------: | +| Cell | Cell | +| Cell | Cell | +| Footer 1 | Footer 2 | + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Left_Aligned_Table_Columns_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Left_Aligned_Table_Columns_As_Expected.verified.txt new file mode 100644 index 0000000..2cab4fe --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Left_Aligned_Table_Columns_As_Expected.verified.txt @@ -0,0 +1,7 @@ + +| Header 1 | Header 2 | +| -------- | :------- | +| Cell | Cell | +| Cell | Cell | +| Footer 1 | Footer 2 | + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Right_Aligned_Table_Columns_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Right_Aligned_Table_Columns_As_Expected.verified.txt new file mode 100644 index 0000000..91856ab --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.MarkdownBorder.Should_Render_Right_Aligned_Table_Columns_As_Expected.verified.txt @@ -0,0 +1,7 @@ + +| Header 1 | Header 2 | +| -------- | -------: | +| Cell | Cell | +| Cell | Cell | +| Footer 1 | Footer 2 | + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..e4cd381 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ + + Header 1 │ Header 2 + ──────────┼────────── + Cell │ Cell + Cell │ Cell + ──────────┼────────── + Footer 1 │ Footer 2 + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalDoubleHeadBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalDoubleHeadBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..0147030 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalDoubleHeadBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ + + Header 1 │ Header 2 + ══════════╪══════════ + Cell │ Cell + Cell │ Cell + ══════════╪══════════ + Footer 1 │ Footer 2 + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalHeavyHeadBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalHeavyHeadBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..ef30305 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.MinimalHeavyHeadBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ + + Header 1 │ Header 2 + ━━━━━━━━━━┿━━━━━━━━━━ + Cell │ Cell + Cell │ Cell + ━━━━━━━━━━┿━━━━━━━━━━ + Footer 1 │ Footer 2 + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.NoBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.NoBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..d4b908b --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.NoBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,4 @@ +Header 1 Header 2 +Cell Cell +Cell Cell +Footer 1 Footer 2 diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.RoundedBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.RoundedBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..6d8b558 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.RoundedBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ +╭──────────┬──────────╮ +│ Header 1 │ Header 2 │ +├──────────┼──────────┤ +│ Cell │ Cell │ +│ Cell │ Cell │ +├──────────┼──────────┤ +│ Footer 1 │ Footer 2 │ +╰──────────┴──────────╯ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.SimpleBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.SimpleBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..9958581 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.SimpleBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ + + Header 1 Header 2 +─────────────────────── + Cell Cell + Cell Cell +─────────────────────── + Footer 1 Footer 2 + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.SimpleHeavyBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.SimpleHeavyBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..7822690 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.SimpleHeavyBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ + + Header 1 Header 2 +━━━━━━━━━━━━━━━━━━━━━━━ + Cell Cell + Cell Cell +━━━━━━━━━━━━━━━━━━━━━━━ + Footer 1 Footer 2 + diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.SquareBorder.Should_Render_As_Expected.verified.txt b/src/Spectre.Console.Tests/Unit/TableBorderTests.SquareBorder.Should_Render_As_Expected.verified.txt new file mode 100644 index 0000000..248b07e --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.SquareBorder.Should_Render_As_Expected.verified.txt @@ -0,0 +1,8 @@ +┌──────────┬──────────┐ +│ Header 1 │ Header 2 │ +├──────────┼──────────┤ +│ Cell │ Cell │ +│ Cell │ Cell │ +├──────────┼──────────┤ +│ Footer 1 │ Footer 2 │ +└──────────┴──────────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableBorderTests.cs b/src/Spectre.Console.Tests/Unit/TableBorderTests.cs index 8b47969..9167067 100644 --- a/src/Spectre.Console.Tests/Unit/TableBorderTests.cs +++ b/src/Spectre.Console.Tests/Unit/TableBorderTests.cs @@ -1,11 +1,15 @@ +using System.Threading.Tasks; using Shouldly; using Spectre.Console.Rendering; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class TableBorderTests { + [UsesVerify] public sealed class NoBorder { [Fact] @@ -32,7 +36,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -42,14 +46,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(4); - console.Lines[0].ShouldBe("Header 1 Header 2"); - console.Lines[1].ShouldBe("Cell Cell "); - console.Lines[2].ShouldBe("Cell Cell "); - console.Lines[3].ShouldBe("Footer 1 Footer 2"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class AsciiBorder { [Fact] @@ -76,7 +77,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -86,18 +87,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("+---------------------+"); - console.Lines[1].ShouldBe("| Header 1 | Header 2 |"); - console.Lines[2].ShouldBe("|----------+----------|"); - console.Lines[3].ShouldBe("| Cell | Cell |"); - console.Lines[4].ShouldBe("| Cell | Cell |"); - console.Lines[5].ShouldBe("|----------+----------|"); - console.Lines[6].ShouldBe("| Footer 1 | Footer 2 |"); - console.Lines[7].ShouldBe("+---------------------+"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class Ascii2Border { [Fact] @@ -124,7 +118,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -134,18 +128,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("+----------+----------+"); - console.Lines[1].ShouldBe("| Header 1 | Header 2 |"); - console.Lines[2].ShouldBe("|----------+----------|"); - console.Lines[3].ShouldBe("| Cell | Cell |"); - console.Lines[4].ShouldBe("| Cell | Cell |"); - console.Lines[5].ShouldBe("|----------+----------|"); - console.Lines[6].ShouldBe("| Footer 1 | Footer 2 |"); - console.Lines[7].ShouldBe("+----------+----------+"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class AsciiDoubleHeadBorder { [Fact] @@ -172,7 +159,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -182,18 +169,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("+----------+----------+"); - console.Lines[1].ShouldBe("| Header 1 | Header 2 |"); - console.Lines[2].ShouldBe("|==========+==========|"); - console.Lines[3].ShouldBe("| Cell | Cell |"); - console.Lines[4].ShouldBe("| Cell | Cell |"); - console.Lines[5].ShouldBe("+----------+----------+"); - console.Lines[6].ShouldBe("| Footer 1 | Footer 2 |"); - console.Lines[7].ShouldBe("+----------+----------+"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class SquareBorder { [Fact] @@ -220,7 +200,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -230,18 +210,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("┌──────────┬──────────┐"); - console.Lines[1].ShouldBe("│ Header 1 │ Header 2 │"); - console.Lines[2].ShouldBe("├──────────┼──────────┤"); - console.Lines[3].ShouldBe("│ Cell │ Cell │"); - console.Lines[4].ShouldBe("│ Cell │ Cell │"); - console.Lines[5].ShouldBe("├──────────┼──────────┤"); - console.Lines[6].ShouldBe("│ Footer 1 │ Footer 2 │"); - console.Lines[7].ShouldBe("└──────────┴──────────┘"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class RoundedBorder { [Fact] @@ -268,7 +241,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -278,18 +251,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("╭──────────┬──────────╮"); - console.Lines[1].ShouldBe("│ Header 1 │ Header 2 │"); - console.Lines[2].ShouldBe("├──────────┼──────────┤"); - console.Lines[3].ShouldBe("│ Cell │ Cell │"); - console.Lines[4].ShouldBe("│ Cell │ Cell │"); - console.Lines[5].ShouldBe("├──────────┼──────────┤"); - console.Lines[6].ShouldBe("│ Footer 1 │ Footer 2 │"); - console.Lines[7].ShouldBe("╰──────────┴──────────╯"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class MinimalBorder { [Fact] @@ -316,7 +282,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -326,18 +292,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe(" Header 1 │ Header 2 "); - console.Lines[2].ShouldBe(" ──────────┼────────── "); - console.Lines[3].ShouldBe(" Cell │ Cell "); - console.Lines[4].ShouldBe(" Cell │ Cell "); - console.Lines[5].ShouldBe(" ──────────┼────────── "); - console.Lines[6].ShouldBe(" Footer 1 │ Footer 2 "); - console.Lines[7].ShouldBe(" "); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class MinimalHeavyHeadBorder { [Fact] @@ -364,7 +323,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -374,18 +333,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe(" Header 1 │ Header 2 "); - console.Lines[2].ShouldBe(" ━━━━━━━━━━┿━━━━━━━━━━ "); - console.Lines[3].ShouldBe(" Cell │ Cell "); - console.Lines[4].ShouldBe(" Cell │ Cell "); - console.Lines[5].ShouldBe(" ━━━━━━━━━━┿━━━━━━━━━━ "); - console.Lines[6].ShouldBe(" Footer 1 │ Footer 2 "); - console.Lines[7].ShouldBe(" "); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class MinimalDoubleHeadBorder { [Fact] @@ -412,7 +364,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -422,18 +374,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe(" Header 1 │ Header 2 "); - console.Lines[2].ShouldBe(" ══════════╪══════════ "); - console.Lines[3].ShouldBe(" Cell │ Cell "); - console.Lines[4].ShouldBe(" Cell │ Cell "); - console.Lines[5].ShouldBe(" ══════════╪══════════ "); - console.Lines[6].ShouldBe(" Footer 1 │ Footer 2 "); - console.Lines[7].ShouldBe(" "); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class SimpleBorder { [Fact] @@ -460,7 +405,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -470,18 +415,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe(" Header 1 Header 2 "); - console.Lines[2].ShouldBe("───────────────────────"); - console.Lines[3].ShouldBe(" Cell Cell "); - console.Lines[4].ShouldBe(" Cell Cell "); - console.Lines[5].ShouldBe("───────────────────────"); - console.Lines[6].ShouldBe(" Footer 1 Footer 2 "); - console.Lines[7].ShouldBe(" "); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class HorizontalBorder { [Fact] @@ -508,7 +446,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -518,18 +456,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("───────────────────────"); - console.Lines[1].ShouldBe(" Header 1 Header 2 "); - console.Lines[2].ShouldBe("───────────────────────"); - console.Lines[3].ShouldBe(" Cell Cell "); - console.Lines[4].ShouldBe(" Cell Cell "); - console.Lines[5].ShouldBe("───────────────────────"); - console.Lines[6].ShouldBe(" Footer 1 Footer 2 "); - console.Lines[7].ShouldBe("───────────────────────"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class SimpleHeavyBorder { [Fact] @@ -556,7 +487,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -566,18 +497,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe(" Header 1 Header 2 "); - console.Lines[2].ShouldBe("━━━━━━━━━━━━━━━━━━━━━━━"); - console.Lines[3].ShouldBe(" Cell Cell "); - console.Lines[4].ShouldBe(" Cell Cell "); - console.Lines[5].ShouldBe("━━━━━━━━━━━━━━━━━━━━━━━"); - console.Lines[6].ShouldBe(" Footer 1 Footer 2 "); - console.Lines[7].ShouldBe(" "); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class HeavyBorder { [Fact] @@ -604,7 +528,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -614,18 +538,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("┏━━━━━━━━━━┳━━━━━━━━━━┓"); - console.Lines[1].ShouldBe("┃ Header 1 ┃ Header 2 ┃"); - console.Lines[2].ShouldBe("┣━━━━━━━━━━╋━━━━━━━━━━┫"); - console.Lines[3].ShouldBe("┃ Cell ┃ Cell ┃"); - console.Lines[4].ShouldBe("┃ Cell ┃ Cell ┃"); - console.Lines[5].ShouldBe("┣━━━━━━━━━━╋━━━━━━━━━━┫"); - console.Lines[6].ShouldBe("┃ Footer 1 ┃ Footer 2 ┃"); - console.Lines[7].ShouldBe("┗━━━━━━━━━━┻━━━━━━━━━━┛"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class HeavyEdgeBorder { [Fact] @@ -652,7 +569,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -662,18 +579,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("┏━━━━━━━━━━┯━━━━━━━━━━┓"); - console.Lines[1].ShouldBe("┃ Header 1 │ Header 2 ┃"); - console.Lines[2].ShouldBe("┠──────────┼──────────┨"); - console.Lines[3].ShouldBe("┃ Cell │ Cell ┃"); - console.Lines[4].ShouldBe("┃ Cell │ Cell ┃"); - console.Lines[5].ShouldBe("┠──────────┼──────────┨"); - console.Lines[6].ShouldBe("┃ Footer 1 │ Footer 2 ┃"); - console.Lines[7].ShouldBe("┗━━━━━━━━━━┷━━━━━━━━━━┛"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class HeavyHeadBorder { [Fact] @@ -700,7 +610,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -710,18 +620,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("┏━━━━━━━━━━┳━━━━━━━━━━┓"); - console.Lines[1].ShouldBe("┃ Header 1 ┃ Header 2 ┃"); - console.Lines[2].ShouldBe("┡━━━━━━━━━━╇━━━━━━━━━━┩"); - console.Lines[3].ShouldBe("│ Cell │ Cell │"); - console.Lines[4].ShouldBe("│ Cell │ Cell │"); - console.Lines[5].ShouldBe("├──────────┼──────────┤"); - console.Lines[6].ShouldBe("│ Footer 1 │ Footer 2 │"); - console.Lines[7].ShouldBe("└──────────┴──────────┘"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class DoubleBorder { [Fact] @@ -748,7 +651,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -758,18 +661,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("╔══════════╦══════════╗"); - console.Lines[1].ShouldBe("║ Header 1 ║ Header 2 ║"); - console.Lines[2].ShouldBe("╠══════════╬══════════╣"); - console.Lines[3].ShouldBe("║ Cell ║ Cell ║"); - console.Lines[4].ShouldBe("║ Cell ║ Cell ║"); - console.Lines[5].ShouldBe("╠══════════╬══════════╣"); - console.Lines[6].ShouldBe("║ Footer 1 ║ Footer 2 ║"); - console.Lines[7].ShouldBe("╚══════════╩══════════╝"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class DoubleEdgeBorder { [Fact] @@ -796,7 +692,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -806,18 +702,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("╔══════════╤══════════╗"); - console.Lines[1].ShouldBe("║ Header 1 │ Header 2 ║"); - console.Lines[2].ShouldBe("╟──────────┼──────────╢"); - console.Lines[3].ShouldBe("║ Cell │ Cell ║"); - console.Lines[4].ShouldBe("║ Cell │ Cell ║"); - console.Lines[5].ShouldBe("╟──────────┼──────────╢"); - console.Lines[6].ShouldBe("║ Footer 1 │ Footer 2 ║"); - console.Lines[7].ShouldBe("╚══════════╧══════════╝"); + return Verifier.Verify(console.Output); } } + [UsesVerify] public sealed class MarkdownBorder { [Fact] @@ -844,7 +733,7 @@ namespace Spectre.Console.Tests.Unit } [Fact] - public void Should_Render_As_Expected() + public Task Should_Render_As_Expected() { // Given var console = new PlainConsole(); @@ -854,18 +743,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe("| Header 1 | Header 2 |"); - console.Lines[2].ShouldBe("| -------- | -------- |"); - console.Lines[3].ShouldBe("| Cell | Cell |"); - console.Lines[4].ShouldBe("| Cell | Cell |"); - console.Lines[5].ShouldBe("| Footer 1 | Footer 2 |"); - console.Lines[6].ShouldBe(" "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Left_Aligned_Table_Columns_As_Expected() + public Task Should_Render_Left_Aligned_Table_Columns_As_Expected() { // Given var console = new PlainConsole(); @@ -875,18 +757,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe("| Header 1 | Header 2 |"); - console.Lines[2].ShouldBe("| -------- | :------- |"); - console.Lines[3].ShouldBe("| Cell | Cell |"); - console.Lines[4].ShouldBe("| Cell | Cell |"); - console.Lines[5].ShouldBe("| Footer 1 | Footer 2 |"); - console.Lines[6].ShouldBe(" "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Center_Aligned_Table_Columns_As_Expected() + public Task Should_Render_Center_Aligned_Table_Columns_As_Expected() { // Given var console = new PlainConsole(); @@ -896,18 +771,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe("| Header 1 | Header 2 |"); - console.Lines[2].ShouldBe("| -------- | :------: |"); - console.Lines[3].ShouldBe("| Cell | Cell |"); - console.Lines[4].ShouldBe("| Cell | Cell |"); - console.Lines[5].ShouldBe("| Footer 1 | Footer 2 |"); - console.Lines[6].ShouldBe(" "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Right_Aligned_Table_Columns_As_Expected() + public Task Should_Render_Right_Aligned_Table_Columns_As_Expected() { // Given var console = new PlainConsole(); @@ -917,14 +785,7 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe(" "); - console.Lines[1].ShouldBe("| Header 1 | Header 2 |"); - console.Lines[2].ShouldBe("| -------- | -------: |"); - console.Lines[3].ShouldBe("| Cell | Cell |"); - console.Lines[4].ShouldBe("| Cell | Cell |"); - console.Lines[5].ShouldBe("| Footer 1 | Footer 2 |"); - console.Lines[6].ShouldBe(" "); + return Verifier.Verify(console.Output); } } diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Center_Table_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Center_Table_Correctly.verified.txt new file mode 100644 index 0000000..c850090 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Center_Table_Correctly.verified.txt @@ -0,0 +1,6 @@ + ┌────────┬────────┬───────┐ + │ Foo │ Bar │ Baz │ + ├────────┼────────┼───────┤ + │ Qux │ Corgi │ Waldo │ + │ Grault │ Garply │ Fred │ + └────────┴────────┴───────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Center_Table_With_Title_And_Caption_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Center_Table_With_Title_And_Caption_Correctly.verified.txt new file mode 100644 index 0000000..5a6313c --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Center_Table_With_Title_And_Caption_Correctly.verified.txt @@ -0,0 +1,8 @@ + Hello World + ╭────────┬────────┬───────╮ + │ Foo │ Bar │ Baz │ + ├────────┼────────┼───────┤ + │ Qux │ Corgi │ Waldo │ + │ Grault │ Garply │ Fred │ + ╰────────┴────────┴───────╯ + Goodbye World diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Expand_Table_To_Available_Space_If_Specified.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Expand_Table_To_Available_Space_If_Specified.verified.txt new file mode 100644 index 0000000..ca5fccd --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Expand_Table_To_Available_Space_If_Specified.verified.txt @@ -0,0 +1,6 @@ +┌───────────────────────────┬───────────────────────────┬──────────────────────┐ +│ Foo │ Bar │ Baz │ +├───────────────────────────┼───────────────────────────┼──────────────────────┤ +│ Qux │ Corgi │ Waldo │ +│ Grault │ Garply │ Fred │ +└───────────────────────────┴───────────────────────────┴──────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Left_Align_Table_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Left_Align_Table_Correctly.verified.txt new file mode 100644 index 0000000..5f13934 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Left_Align_Table_Correctly.verified.txt @@ -0,0 +1,6 @@ +┌────────┬────────┬───────┐ +│ Foo │ Bar │ Baz │ +├────────┼────────┼───────┤ +│ Qux │ Corgi │ Waldo │ +│ Grault │ Garply │ Fred │ +└────────┴────────┴───────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Left_Align_Table_With_Title_And_Caption_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Left_Align_Table_With_Title_And_Caption_Correctly.verified.txt new file mode 100644 index 0000000..82feb06 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Left_Align_Table_With_Title_And_Caption_Correctly.verified.txt @@ -0,0 +1,8 @@ + Hello World +╭────────┬────────┬───────╮ +│ Foo │ Bar │ Baz │ +├────────┼────────┼───────┤ +│ Qux │ Corgi │ Waldo │ +│ Grault │ Garply │ Fred │ +╰────────┴────────┴───────╯ + Goodbye World diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Not_Draw_Tables_That_Are_Impossible_To_Draw.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Not_Draw_Tables_That_Are_Impossible_To_Draw.verified.txt new file mode 100644 index 0000000..379a628 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Not_Draw_Tables_That_Are_Impossible_To_Draw.verified.txt @@ -0,0 +1,12 @@ +╭───────┬───────┬───────╮ +│ ┌───┐ │ ┌───┐ │ ┌───┐ │ +│ │ A │ │ │ D │ │ │ G │ │ +│ │ B │ │ │ E │ │ │ H │ │ +│ │ C │ │ │ F │ │ │ I │ │ +│ └───┘ │ └───┘ │ └───┘ │ +├───────┼───────┼───────┤ +│ Hello │ World │ │ +│ … │ Whaat │ Lol │ +│ Hej │ Värld │ │ +│ │ en │ │ +╰───────┴───────┴───────╯ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Correctly.verified.txt new file mode 100644 index 0000000..5f13934 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Correctly.verified.txt @@ -0,0 +1,6 @@ +┌────────┬────────┬───────┐ +│ Foo │ Bar │ Baz │ +├────────┼────────┼───────┤ +│ Qux │ Corgi │ Waldo │ +│ Grault │ Garply │ Fred │ +└────────┴────────┴───────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Nested_In_Panels_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Nested_In_Panels_Correctly.verified.txt new file mode 100644 index 0000000..a527173 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Nested_In_Panels_Correctly.verified.txt @@ -0,0 +1,11 @@ +┌───────────────────────────────────┐ +│ +-------------------------------+ │ +│ | ╭──────────┬────────┬───────╮ | │ +│ | │ Foo │ Bar │ Baz │ | │ +│ | ├──────────┼────────┼───────┤ | │ +│ | │ Qux │ Corgi │ Waldo │ | │ +│ | │ Quuuuuux │ │ │ | │ +│ | │ Grault │ Garply │ Fred │ | │ +│ | ╰──────────┴────────┴───────╯ | │ +│ +-------------------------------+ │ +└───────────────────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Cell_Padding_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Cell_Padding_Correctly.verified.txt new file mode 100644 index 0000000..6eacc84 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Cell_Padding_Correctly.verified.txt @@ -0,0 +1,7 @@ +┌────────┬────────┬──────────┐ +│ Foo │ Bar │ Baz │ +├────────┼────────┼──────────┤ +│ Qux │ Corgi │ Waldo │ +│ Quuux │ │ │ +│ Grault │ Garply │ Fred │ +└────────┴────────┴──────────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Column_Justification_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Column_Justification_Correctly.verified.txt new file mode 100644 index 0000000..6776044 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Column_Justification_Correctly.verified.txt @@ -0,0 +1,6 @@ +┌────────┬────────┬────────────────────────────┐ +│ Foo │ Bar │ Baz │ +├────────┼────────┼────────────────────────────┤ +│ Qux │ Corgi │ Waldo │ +│ Grault │ Garply │ Lorem ipsum dolor sit amet │ +└────────┴────────┴────────────────────────────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Footers_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Footers_Correctly.verified.txt new file mode 100644 index 0000000..244b1b7 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Footers_Correctly.verified.txt @@ -0,0 +1,8 @@ +┌────────┬────────┬───────┐ +│ Foo │ Bar │ Baz │ +├────────┼────────┼───────┤ +│ Qux │ Corgi │ Waldo │ +│ Grault │ Garply │ Fred │ +├────────┼────────┼───────┤ +│ Oof │ │ Zab │ +└────────┴────────┴───────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Multiple_Rows_In_Cell_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Multiple_Rows_In_Cell_Correctly.verified.txt new file mode 100644 index 0000000..5114854 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Multiple_Rows_In_Cell_Correctly.verified.txt @@ -0,0 +1,7 @@ +┌────────┬────────┬───────┐ +│ Foo │ Bar │ Baz │ +├────────┼────────┼───────┤ +│ Qux │ Corgi │ Waldo │ +│ Quuux │ │ │ +│ Grault │ Garply │ Fred │ +└────────┴────────┴───────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_No_Border_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_No_Border_Correctly.verified.txt new file mode 100644 index 0000000..2ce9e29 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_No_Border_Correctly.verified.txt @@ -0,0 +1,3 @@ +Foo Bar Baz +Qux Corgi Waldo +Grault Garply Fred diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Title_And_Caption_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Title_And_Caption_Correctly.verified.txt new file mode 100644 index 0000000..82feb06 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_With_Title_And_Caption_Correctly.verified.txt @@ -0,0 +1,8 @@ + Hello World +╭────────┬────────┬───────╮ +│ Foo │ Bar │ Baz │ +├────────┼────────┼───────┤ +│ Qux │ Corgi │ Waldo │ +│ Grault │ Garply │ Fred │ +╰────────┴────────┴───────╯ + Goodbye World diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Without_Rows.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Without_Rows.verified.txt new file mode 100644 index 0000000..8b32b8d --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Render_Table_Without_Rows.verified.txt @@ -0,0 +1,3 @@ +┌─────┬─────┬────────┐ +│ Foo │ Bar │ Baz │ +└─────┴─────┴────────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Right_Align_Table_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Right_Align_Table_Correctly.verified.txt new file mode 100644 index 0000000..3b73d52 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Right_Align_Table_Correctly.verified.txt @@ -0,0 +1,6 @@ + ┌────────┬────────┬───────┐ + │ Foo │ Bar │ Baz │ + ├────────┼────────┼───────┤ + │ Qux │ Corgi │ Waldo │ + │ Grault │ Garply │ Fred │ + └────────┴────────┴───────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.Should_Right_Align_Table_With_Title_And_Caption_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.Should_Right_Align_Table_With_Title_And_Caption_Correctly.verified.txt new file mode 100644 index 0000000..d11f171 --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.Should_Right_Align_Table_With_Title_And_Caption_Correctly.verified.txt @@ -0,0 +1,8 @@ + Hello World + ╭────────┬────────┬───────╮ + │ Foo │ Bar │ Baz │ + ├────────┼────────┼───────┤ + │ Qux │ Corgi │ Waldo │ + │ Grault │ Garply │ Fred │ + ╰────────┴────────┴───────╯ + Goodbye World diff --git a/src/Spectre.Console.Tests/Unit/TableTests.TheAddEmptyRowMethod.Should_Render_Table_Correctly.verified.txt b/src/Spectre.Console.Tests/Unit/TableTests.TheAddEmptyRowMethod.Should_Render_Table_Correctly.verified.txt new file mode 100644 index 0000000..cbde18e --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/TableTests.TheAddEmptyRowMethod.Should_Render_Table_Correctly.verified.txt @@ -0,0 +1,7 @@ +┌────────┬────────┬───────┐ +│ Foo │ Bar │ Baz │ +├────────┼────────┼───────┤ +│ Qux │ Corgi │ Waldo │ +│ │ │ │ +│ Grault │ Garply │ Fred │ +└────────┴────────┴───────┘ diff --git a/src/Spectre.Console.Tests/Unit/TableTests.cs b/src/Spectre.Console.Tests/Unit/TableTests.cs index 384ba8f..69f372f 100644 --- a/src/Spectre.Console.Tests/Unit/TableTests.cs +++ b/src/Spectre.Console.Tests/Unit/TableTests.cs @@ -1,9 +1,12 @@ using System; +using System.Threading.Tasks; using Shouldly; +using VerifyXunit; using Xunit; namespace Spectre.Console.Tests.Unit { + [UsesVerify] public sealed class TableTests { public sealed class TheAddColumnMethod @@ -117,10 +120,11 @@ namespace Spectre.Console.Tests.Unit } } + [UsesVerify] public sealed class TheAddEmptyRowMethod { [Fact] - public void Should_Render_Table_Correctly() + public Task Should_Render_Table_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -134,19 +138,12 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe("┌────────┬────────┬───────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("├────────┼────────┼───────┤"); - console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe("│ │ │ │"); - console.Lines[5].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[6].ShouldBe("└────────┴────────┴───────┘"); + return Verifier.Verify(console.Output); } } [Fact] - public void Should_Render_Table_Correctly() + public Task Should_Render_Table_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -159,17 +156,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(6); - console.Lines[0].ShouldBe("┌────────┬────────┬───────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("├────────┼────────┼───────┤"); - console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[5].ShouldBe("└────────┴────────┴───────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Table_With_Footers_Correctly() + public Task Should_Render_Table_With_Footers_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -184,19 +175,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe("┌────────┬────────┬───────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("├────────┼────────┼───────┤"); - console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[5].ShouldBe("├────────┼────────┼───────┤"); - console.Lines[6].ShouldBe("│ Oof │ │ Zab │"); - console.Lines[7].ShouldBe("└────────┴────────┴───────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Left_Align_Table_Correctly() + public Task Should_Left_Align_Table_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -210,17 +193,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(6); - console.Lines[0].ShouldBe("┌────────┬────────┬───────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("├────────┼────────┼───────┤"); - console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[5].ShouldBe("└────────┴────────┴───────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Center_Table_Correctly() + public Task Should_Center_Table_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -234,17 +211,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(6); - console.Lines[0].ShouldBe(" ┌────────┬────────┬───────┐ "); - console.Lines[1].ShouldBe(" │ Foo │ Bar │ Baz │ "); - console.Lines[2].ShouldBe(" ├────────┼────────┼───────┤ "); - console.Lines[3].ShouldBe(" │ Qux │ Corgi │ Waldo │ "); - console.Lines[4].ShouldBe(" │ Grault │ Garply │ Fred │ "); - console.Lines[5].ShouldBe(" └────────┴────────┴───────┘ "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Right_Align_Table_Correctly() + public Task Should_Right_Align_Table_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -258,17 +229,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(6); - console.Lines[0].ShouldBe(" ┌────────┬────────┬───────┐"); - console.Lines[1].ShouldBe(" │ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe(" ├────────┼────────┼───────┤"); - console.Lines[3].ShouldBe(" │ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe(" │ Grault │ Garply │ Fred │"); - console.Lines[5].ShouldBe(" └────────┴────────┴───────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Table_Nested_In_Panels_Correctly() + public Task Should_Render_Table_Nested_In_Panels_Correctly() { // A simple table var console = new PlainConsole(width: 80); @@ -286,22 +251,11 @@ namespace Spectre.Console.Tests.Unit })); // Then - console.Lines.Count.ShouldBe(11); - console.Lines[00].ShouldBe("┌───────────────────────────────────┐"); - console.Lines[01].ShouldBe("│ +-------------------------------+ │"); - console.Lines[02].ShouldBe("│ | ╭──────────┬────────┬───────╮ | │"); - console.Lines[03].ShouldBe("│ | │ Foo │ Bar │ Baz │ | │"); - console.Lines[04].ShouldBe("│ | ├──────────┼────────┼───────┤ | │"); - console.Lines[05].ShouldBe("│ | │ Qux │ Corgi │ Waldo │ | │"); - console.Lines[06].ShouldBe("│ | │ Quuuuuux │ │ │ | │"); - console.Lines[07].ShouldBe("│ | │ Grault │ Garply │ Fred │ | │"); - console.Lines[08].ShouldBe("│ | ╰──────────┴────────┴───────╯ | │"); - console.Lines[09].ShouldBe("│ +-------------------------------+ │"); - console.Lines[10].ShouldBe("└───────────────────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Table_With_Column_Justification_Correctly() + public Task Should_Render_Table_With_Column_Justification_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -316,17 +270,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(6); - console.Lines[0].ShouldBe("┌────────┬────────┬────────────────────────────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("├────────┼────────┼────────────────────────────┤"); - console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe("│ Grault │ Garply │ Lorem ipsum dolor sit amet │"); - console.Lines[5].ShouldBe("└────────┴────────┴────────────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Expand_Table_To_Available_Space_If_Specified() + public Task Should_Expand_Table_To_Available_Space_If_Specified() { // Given var console = new PlainConsole(width: 80); @@ -339,18 +287,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(6); - console.Lines[0].Length.ShouldBe(80); - console.Lines[0].ShouldBe("┌───────────────────────────┬───────────────────────────┬──────────────────────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("├───────────────────────────┼───────────────────────────┼──────────────────────┤"); - console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[5].ShouldBe("└───────────────────────────┴───────────────────────────┴──────────────────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Table_With_No_Border_Correctly() + public Task Should_Render_Table_With_No_Border_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -363,14 +304,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("Foo Bar Baz "); - console.Lines[1].ShouldBe("Qux Corgi Waldo"); - console.Lines[2].ShouldBe("Grault Garply Fred "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Table_With_Multiple_Rows_In_Cell_Correctly() + public Task Should_Render_Table_With_Multiple_Rows_In_Cell_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -383,18 +321,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe("┌────────┬────────┬───────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("├────────┼────────┼───────┤"); - console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe("│ Quuux │ │ │"); - console.Lines[5].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[6].ShouldBe("└────────┴────────┴───────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Table_With_Cell_Padding_Correctly() + public Task Should_Render_Table_With_Cell_Padding_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -408,18 +339,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(7); - console.Lines[0].ShouldBe("┌────────┬────────┬──────────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("├────────┼────────┼──────────┤"); - console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[4].ShouldBe("│ Quuux │ │ │"); - console.Lines[5].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[6].ShouldBe("└────────┴────────┴──────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Table_Without_Footer_If_No_Rows_Are_Added() + public Task Should_Render_Table_Without_Rows() { // Given var console = new PlainConsole(width: 80); @@ -431,14 +355,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(3); - console.Lines[0].ShouldBe("┌─────┬─────┬────────┐"); - console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[2].ShouldBe("└─────┴─────┴────────┘"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Not_Draw_Tables_That_Are_Impossible_To_Draw() + public Task Should_Not_Draw_Tables_That_Are_Impossible_To_Draw() { // Given var console = new PlainConsole(width: 25); @@ -471,23 +392,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(12); - console.Lines[00].ShouldBe("╭───────┬───────┬───────╮"); - console.Lines[01].ShouldBe("│ ┌───┐ │ ┌───┐ │ ┌───┐ │"); - console.Lines[02].ShouldBe("│ │ A │ │ │ D │ │ │ G │ │"); - console.Lines[03].ShouldBe("│ │ B │ │ │ E │ │ │ H │ │"); - console.Lines[04].ShouldBe("│ │ C │ │ │ F │ │ │ I │ │"); - console.Lines[05].ShouldBe("│ └───┘ │ └───┘ │ └───┘ │"); - console.Lines[06].ShouldBe("├───────┼───────┼───────┤"); - console.Lines[07].ShouldBe("│ Hello │ World │ │"); - console.Lines[08].ShouldBe("│ … │ Whaat │ Lol │"); - console.Lines[09].ShouldBe("│ Hej │ Värld │ │"); - console.Lines[10].ShouldBe("│ │ en │ │"); - console.Lines[11].ShouldBe("╰───────┴───────┴───────╯"); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Render_Table_With_Title_And_Caption_Correctly() + public Task Should_Render_Table_With_Title_And_Caption_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -502,19 +411,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" Hello World "); - console.Lines[1].ShouldBe("╭────────┬────────┬───────╮"); - console.Lines[2].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[3].ShouldBe("├────────┼────────┼───────┤"); - console.Lines[4].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[5].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[6].ShouldBe("╰────────┴────────┴───────╯"); - console.Lines[7].ShouldBe(" Goodbye World "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Left_Align_Table_With_Title_And_Caption_Correctly() + public Task Should_Left_Align_Table_With_Title_And_Caption_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -530,19 +431,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" Hello World "); - console.Lines[1].ShouldBe("╭────────┬────────┬───────╮"); - console.Lines[2].ShouldBe("│ Foo │ Bar │ Baz │"); - console.Lines[3].ShouldBe("├────────┼────────┼───────┤"); - console.Lines[4].ShouldBe("│ Qux │ Corgi │ Waldo │"); - console.Lines[5].ShouldBe("│ Grault │ Garply │ Fred │"); - console.Lines[6].ShouldBe("╰────────┴────────┴───────╯"); - console.Lines[7].ShouldBe(" Goodbye World "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Center_Table_With_Title_And_Caption_Correctly() + public Task Should_Center_Table_With_Title_And_Caption_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -558,19 +451,11 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" Hello World "); - console.Lines[1].ShouldBe(" ╭────────┬────────┬───────╮ "); - console.Lines[2].ShouldBe(" │ Foo │ Bar │ Baz │ "); - console.Lines[3].ShouldBe(" ├────────┼────────┼───────┤ "); - console.Lines[4].ShouldBe(" │ Qux │ Corgi │ Waldo │ "); - console.Lines[5].ShouldBe(" │ Grault │ Garply │ Fred │ "); - console.Lines[6].ShouldBe(" ╰────────┴────────┴───────╯ "); - console.Lines[7].ShouldBe(" Goodbye World "); + return Verifier.Verify(console.Output); } [Fact] - public void Should_Right_Align_Table_With_Title_And_Caption_Correctly() + public Task Should_Right_Align_Table_With_Title_And_Caption_Correctly() { // Given var console = new PlainConsole(width: 80); @@ -586,15 +471,7 @@ namespace Spectre.Console.Tests.Unit console.Render(table); // Then - console.Lines.Count.ShouldBe(8); - console.Lines[0].ShouldBe(" Hello World "); - console.Lines[1].ShouldBe(" ╭────────┬────────┬───────╮"); - console.Lines[2].ShouldBe(" │ Foo │ Bar │ Baz │"); - console.Lines[3].ShouldBe(" ├────────┼────────┼───────┤"); - console.Lines[4].ShouldBe(" │ Qux │ Corgi │ Waldo │"); - console.Lines[5].ShouldBe(" │ Grault │ Garply │ Fred │"); - console.Lines[6].ShouldBe(" ╰────────┴────────┴───────╯"); - console.Lines[7].ShouldBe(" Goodbye World "); + return Verifier.Verify(console.Output); } } } diff --git a/src/Spectre.Console.Tests/Unit/TextTests.cs b/src/Spectre.Console.Tests/Unit/TextTests.cs index 2787884..ad0184c 100644 --- a/src/Spectre.Console.Tests/Unit/TextTests.cs +++ b/src/Spectre.Console.Tests/Unit/TextTests.cs @@ -44,9 +44,7 @@ namespace Spectre.Console.Tests.Unit console.Render(text); // Then - console.Output - .NormalizeLineEndings() - .ShouldBe("Hello World"); + console.Output.ShouldBe("Hello World"); } [Theory] @@ -62,7 +60,7 @@ namespace Spectre.Console.Tests.Unit console.Render(text); // Then - console.RawOutput.ShouldBe("Hello\n\nWorld\n\n"); + console.Output.ShouldBe("Hello\n\nWorld\n\n"); } [Fact] diff --git a/src/Spectre.Console/Rendering/Segment.cs b/src/Spectre.Console/Rendering/Segment.cs index 45b2277..0c3073e 100644 --- a/src/Spectre.Console/Rendering/Segment.cs +++ b/src/Spectre.Console/Rendering/Segment.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; -using Spectre.Console.Internal; namespace Spectre.Console.Rendering { diff --git a/src/Spectre.Console/Widgets/Panel.cs b/src/Spectre.Console/Widgets/Panel.cs index 483d1b6..da550fa 100644 --- a/src/Spectre.Console/Widgets/Panel.cs +++ b/src/Spectre.Console/Widgets/Panel.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Spectre.Console.Internal; using Spectre.Console.Rendering; namespace Spectre.Console diff --git a/src/Spectre.Console/Widgets/Rule.cs b/src/Spectre.Console/Widgets/Rule.cs index dafe8e9..c3b9c2f 100644 --- a/src/Spectre.Console/Widgets/Rule.cs +++ b/src/Spectre.Console/Widgets/Rule.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Spectre.Console.Internal; using Spectre.Console.Rendering; namespace Spectre.Console