Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,204 changes: 2,204 additions & 0 deletions src/Spectre.Console.Tests/Data/figlet/big.flf

Large diffs are not rendered by default.

Binary file added src/Spectre.Console.Tests/Data/figlet/fonts.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1941,25 +1941,38 @@
{
public int Baseline { get; }
public int Count { get; }
public char Hardblank { get; }
public int Height { get; }
public int MaxWidth { get; }
public int SmushingRules { get; }
public static Spectre.Console.FigletFont Default { get; }
public static Spectre.Console.FigletFont Load(System.IO.Stream stream) { }
public static Spectre.Console.FigletFont Load(string path) { }
public static Spectre.Console.FigletFont Parse(string source) { }
}
public enum FigletLayoutMode
{
FullSize = 0,
Fitted = 1,
Smushed = 2,
}
public sealed class FigletText : Spectre.Console.Rendering.Renderable, Spectre.Console.IHasJustification
{
public FigletText(string text) { }
public FigletText(Spectre.Console.FigletFont font, string text) { }
public Spectre.Console.Color? Color { get; set; }
public Spectre.Console.Justify? Justification { get; set; }
public Spectre.Console.FigletLayoutMode LayoutMode { get; set; }
public bool Pad { get; set; }
protected override System.Collections.Generic.IEnumerable<Spectre.Console.Rendering.Segment> Render(Spectre.Console.Rendering.RenderOptions options, int maxWidth) { }
}
public static class FigletTextExtensions
{
public static Spectre.Console.FigletText Color(this Spectre.Console.FigletText text, Spectre.Console.Color? color) { }
public static Spectre.Console.FigletText Fitted(this Spectre.Console.FigletText text) { }
public static Spectre.Console.FigletText FullSize(this Spectre.Console.FigletText text) { }
public static Spectre.Console.FigletText LayoutMode(this Spectre.Console.FigletText text, Spectre.Console.FigletLayoutMode mode) { }
public static Spectre.Console.FigletText Smushed(this Spectre.Console.FigletText text) { }
}
public enum FileSizeBase
{
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
 _____ _ _ _ _
| __ \ | | (_) | | | |
| |__) | __ _ | |_ _ __ _ | | __ __ __ __ _ ___ | |__ ___ _ __ ___
| ___/ / _` | | __| | '__| | | | |/ / \ \ /\ / / / _` | / __| | '_ \ / _ \ | '__| / _ \
| | | (_| | | |_ | | | | | < \ V V / | (_| | \__ \ | | | | | __/ | | | __/
|_| \__,_| \__| |_| |_| |_|\_\ \_/\_/ \__,_| |___/ |_| |_| \___| |_| \___|


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
 ____ _ ____ _
/ ___| _ __ ___ ___ | |_ _ __ ___ / ___| ___ _ __ ___ ___ | | ___
\___ \ | '_ \ / _ \ / __|| __|| '__|/ _ \ | | / _ \ | '_ \ / __| / _ \ | | / _ \
___) || |_) || __/| (__ | |_ | | | __/ _| |___| (_) || | | |\__ \| (_) || || __/
|____/ | .__/ \___| \___| \__||_| \___|(_)\____|\___/ |_| |_||___/ \___/ |_| \___|
|_|
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
 _____
| __ \
| |__) |
| ___/
| |
|_|


Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
 _____ _ _____ _
/ ____| | | / ____| | |
| (___ _ __ ___ ___| |_ _ __ ___ | | ___ _ __ ___ ___ | | ___
\___ \| '_ \ / _ \/ __| __| '__/ _ | | / _ \| '_ \/ __|/ _ \| |/ _ \
____) | |_) | __/ (__| |_| | | __/| |___| (_) | | | \__ \ (_) | | __/
|_____/| .__/ \___|\___|\__|_| \___(_)_____\___/|_| |_|___/\___/|_|\___|
| |
|_|
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
 _____ _ _____ _
/ ____| | | / ____| | |
| (___ _ __ ___ ___| |_ _ __ ___ | | ___ _ __ ___ ___ | | ___
\___ \| '_ \ / _ \/ __| __| '__/ _ | | / _ \| '_ \/ __|/ _ \| |/ _ \
____) | |_) | __/ (__| |_| | | __/| |___| (_) | | | \__ \ (_) | | __/
|_____/| .__/ \___|\___|\__|_| \___(_)_____\___/|_| |_|___/\___/|_|\___|
| |
|_|
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@ @@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@
!@@ @@! @@@@! !@@ @@! @@! @@@@! !@@ @@! @@@@!@!@@!@@
!@! !@! @!!@! !@! !@! !@! @!!@! !@! !@! @!!@!!@!@!@!
!!@@!! @!@@!@!@!!!:! !@! @!! @!@!!@!@!!!:! !@! @!@ !@@!@ !!@!!@@!!
!!@!!!!!@!!! !!!!!: !!! !!! !!@!@! !!!!!: !!! !@! !!!@! !!!!!@!!!
!:!!: !!: :!! !!: !!: :!!!!: :!! !!: !!!!: !!! !:!
!:!:!: :!: :!: :!: :!: !::!: :!:!: :!: !::!: !:! !:!
:::: :: :: :: ::::::: ::: :: :: ::::: ::::::::: ::::::: :::: ::::: ::
:: : : : : :: :: :: :: : : : : : :: ::::::: :: :: : ::: ::: : :


@@@@@@@@@ @@@@@@@@
@@@@@@@@@@ @@@@@@@@
@@! @@@@! @@!
!@! @!!@! !@!
@!@ !@@!! @!!!:!
!@! !!!!! !!!!!:
!!: !!!!: !!:
:!: !:!:!: :!:
::::: :::: :::::: ::::
: : :: :: : : :: ::

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
 _______..______ _______ ______ .___________..______ _______ ______ ______ .__ __.
/ || _ \| ____/ || || _ \ | ____| / | / __ \| \ | |
| (----`| |_) | |__ | ,----'`---| |----`| |_) | | |__ | ,----'| | | | \| |
\ \ | ___/| __|| | | | | / | __| | | | | | | . ` |
.----) | | | | |___| `----. | | | |\ \----.| |____ _| `----.| `--' | |\ |
|_______/ | _| |_______\______| |__| | _| `._____||_______(__)______| \______/|__| \__|

_______. ______ __ _______
/ | / __ \| | | ____|
| (----`| | | | | | |__
\ \ | | | | | | __|
.----) | | `--' | `----.| |____
|_______/ \______/|_______||_______|

11 changes: 9 additions & 2 deletions src/Spectre.Console.Tests/Spectre.Console.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@

<ItemGroup>
<EmbeddedResource Include="Data\example.json" />
<EmbeddedResource Include="Data\starwars.flf" />
<EmbeddedResource Include="Data\poison.flf" />
<EmbeddedResource Include="Data\figlet\fonts.zip" />
<None Remove="Data\example.json" />
<None Remove="Data\starwars.flf" />
<None Remove="Data\poison.flf" />
<None Remove="Data\banner.flf" />
<None Remove="Data\B1FF.flf" />
<None Remove="Data\fonts.zip" />
<EmbeddedResource Include="Data\figlet\big.flf" />
<None Remove="Data\figlet\poison.flf" />
<EmbeddedResource Include="Data\figlet\poison.flf" />
<None Remove="Data\figlet\star_wars.flf" />
<EmbeddedResource Include="Data\figlet\star_wars.flf" />
</ItemGroup>

<ItemGroup>
Expand Down
140 changes: 135 additions & 5 deletions src/Spectre.Console.Tests/Unit/Widgets/FigletTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ namespace Spectre.Console.Tests.Unit;
public sealed class FigletTests
{
[Theory]
[InlineData("starwars.flf")]
[InlineData("poison.flf")]
[InlineData(FigletTestFont.Big)]
[InlineData(FigletTestFont.StarWars)]
[InlineData(FigletTestFont.Poison)]
[Expectation("Load_Stream")]
public async Task Should_Load_Font_From_Stream(string fontfile)
public async Task Should_Load_Font_From_Stream(FigletTestFont name)
{
// Given
var console = new TestConsole().Width(180);
var font = FigletFont.Load(EmbeddedResourceReader.LoadResourceStream($"Spectre.Console.Tests/Data/{fontfile}"));
var font = FigletTestFontLoader.Load(name);
var text = new FigletText(font, "Patrik was here");

// When
console.Write(text);

// Then
await Verifier.Verify(console.Output)
.UseParameters(fontfile);
.UseParameters(
name.ToString().ToLowerInvariant());
}

[Fact]
Expand All @@ -37,6 +39,22 @@ public async Task Should_Render_Text_Correctly()
await Verifier.Verify(console.Output);
}

[Fact]
[Expectation("Render_Single")]
public async Task Should_Render_Single_Character()
{
// Given
var console = new TestConsole().Width(120);
var font = FigletTestFontLoader.Load(FigletTestFont.Big);
var text = new FigletText(font, "P");

// When
console.Write(text);

// Then
await Verifier.Verify(console.Output);
}

[Fact]
[Expectation("Render_Wrapped")]
public async Task Should_Render_Wrapped_Text_Correctly()
Expand Down Expand Up @@ -99,4 +117,116 @@ public async Task Should_Render_Right_Aligned_Text_Correctly()
// Then
await Verifier.Verify(console.Output);
}

[Fact]
[Expectation("Render_Fitted")]
public async Task Should_Render_Fitted_Text_Correctly()
{
// Given
var console = new TestConsole().Width(120);
var text = new FigletText(FigletFont.Default, "Spectre.Console")
{
LayoutMode = FigletLayoutMode.Fitted,
};

// When
console.Write(text);

// Then
await Verifier.Verify(console.Output);
}

[Theory]
[InlineData(FigletTestFont.Big)]
[InlineData(FigletTestFont.StarWars)]
[InlineData(FigletTestFont.Poison)]
[Expectation("Render_Smushed_Universal")]
public async Task Should_Render_Smushed_Text_Correctly_Using_Universal_Smushing_Rules(FigletTestFont name)
{
// Given
var console = new TestConsole().Width(120);
var font = FigletTestFontLoader.Load(name);
var text = new FigletText(font, "Spectre.Console")
{
LayoutMode = FigletLayoutMode.Smushed,
};

// When
console.Write(text);

// Then
await Verifier.Verify(console.Output)
.UseParameters(
name.ToString().ToLowerInvariant());
}

[Fact]
[Expectation("Render_Smushed")]
public async Task Should_Render_Smushed_Text_Correctly_Using_Font_Smushing_Rules()
{
// Given
var console = new TestConsole().Width(120);
var font = FigletTestFontLoader.Load(FigletTestFont.Big);
var text = new FigletText(font, "Spectre.Console")
{
LayoutMode = FigletLayoutMode.Smushed,
};

// When
console.Write(text);

// Then
await Verifier.Verify(console.Output);
}

[Theory]
[InlineData(FigletLayoutMode.FullSize)]
[InlineData(FigletLayoutMode.Fitted)]
[InlineData(FigletLayoutMode.Smushed)]
public void Should_Render_Empty_String(FigletLayoutMode mode)
{
// Given
var console = new TestConsole().Width(120);
var text = new FigletText(FigletFont.Default, string.Empty)
{
LayoutMode = mode,
};

// When
console.Write(text);

// Then
console.Output.ShouldBeEmpty();
}

[Theory]
[InlineData(FigletLayoutMode.FullSize)]
[InlineData(FigletLayoutMode.Fitted)]
[InlineData(FigletLayoutMode.Smushed)]
public void Should_Not_Render_Non_Existent_Glyph(FigletLayoutMode mode)
{
// Given
var console = new TestConsole().Width(120);
var text = new FigletText(FigletFont.Default, "😄")
{
LayoutMode = mode,
};

// When
console.Write(text);

// Then
console.Output.ShouldBeEmpty();
}

[Fact]
[Expectation("Figlet_Report")]
public async Task Figlet_Report()
{
// Given, When
var report = FigletReportGenerator.Generate();

// Then
await Verifier.Verify(report);
}
}
Loading