mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-12-23 10:05:49 +08:00
Moved analyzer tests to its own project
Also moves tests to `./test` which makes it possible for all test projects to share the same .editorconfig files and similar.
This commit is contained in:
96
test/Spectre.Console.Tests/Unit/EmojiTests.cs
Normal file
96
test/Spectre.Console.Tests/Unit/EmojiTests.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using Shouldly;
|
||||
using Spectre.Console.Testing;
|
||||
using Xunit;
|
||||
|
||||
namespace Spectre.Console.Tests.Unit
|
||||
{
|
||||
public sealed class EmojiTests
|
||||
{
|
||||
[Fact]
|
||||
public void Should_Substitute_Emoji_Shortcodes_In_Markdown()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
|
||||
// When
|
||||
console.Markup("Hello :globe_showing_europe_africa:!");
|
||||
|
||||
// Then
|
||||
console.Output.ShouldBe("Hello 🌍!");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Contain_Predefined_Emojis()
|
||||
{
|
||||
// Given, When
|
||||
const string result = "Hello " + Emoji.Known.GlobeShowingEuropeAfrica + "!";
|
||||
|
||||
// Then
|
||||
result.ShouldBe("Hello 🌍!");
|
||||
}
|
||||
|
||||
public sealed class TheReplaceMethod
|
||||
{
|
||||
[Fact]
|
||||
public void Should_Replace_Emojis_In_Text()
|
||||
{
|
||||
// Given, When
|
||||
var result = Emoji.Replace("Hello :globe_showing_europe_africa:!");
|
||||
|
||||
// Then
|
||||
result.ShouldBe("Hello 🌍!");
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Parsing
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(":", ":")]
|
||||
[InlineData("::", "::")]
|
||||
[InlineData(":::", ":::")]
|
||||
[InlineData("::::", "::::")]
|
||||
[InlineData("::i:", "::i:")]
|
||||
[InlineData(":i:i:", ":i:i:")]
|
||||
[InlineData("::globe_showing_europe_africa::", ":🌍:")]
|
||||
[InlineData(":globe_showing_europe_africa::globe_showing_europe_africa:", "🌍🌍")]
|
||||
[InlineData("::globe_showing_europe_africa:::test:::globe_showing_europe_africa:::", ":🌍::test::🌍::")]
|
||||
public void Can_Handle_Different_Combinations(string markup, string expected)
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
|
||||
// When
|
||||
console.Markup(markup);
|
||||
|
||||
// Then
|
||||
console.Output.ShouldBe(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Leave_Single_Colons()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
|
||||
// When
|
||||
console.Markup("Hello :globe_showing_europe_africa:! Output: good");
|
||||
|
||||
// Then
|
||||
console.Output.ShouldBe("Hello 🌍! Output: good");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Unknown_emojis_should_remain_unchanged()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole();
|
||||
|
||||
// When
|
||||
console.Markup("Hello :globe_showing_flat_earth:!");
|
||||
|
||||
// Then
|
||||
console.Output.ShouldBe("Hello :globe_showing_flat_earth:!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user