2022-06-05 19:03:28 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2022-09-06 05:53:22 +00:00
|
|
|
using MfGames.Nitride.Tests;
|
2022-06-05 19:03:28 +00:00
|
|
|
|
|
|
|
using Xunit;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
2022-09-06 05:53:22 +00:00
|
|
|
namespace MfGames.Nitride.Slugs.Tests;
|
2022-06-05 19:03:28 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests the functionality of the WriteFiles().
|
|
|
|
/// </summary>
|
|
|
|
public class UnicodeNormalizingSlugConverterTest : NitrideTestBase
|
|
|
|
{
|
|
|
|
public UnicodeNormalizingSlugConverterTest(ITestOutputHelper output)
|
|
|
|
: base(output)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void DefaultConversions()
|
|
|
|
{
|
|
|
|
var slug = new UnicodeNormalizingSlugConverter();
|
|
|
|
var expected = new List<string>();
|
|
|
|
var actual = new List<string>();
|
|
|
|
|
|
|
|
this.Test(slug, expected, actual, "One", "one");
|
|
|
|
this.Test(slug, expected, actual, "Two-Words", "two-words");
|
|
|
|
this.Test(slug, expected, actual, "Rutejìmo", "rutejimo");
|
|
|
|
this.Test(slug, expected, actual, "C#", "c");
|
|
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void ReplacementConversions()
|
|
|
|
{
|
|
|
|
var slug = new UnicodeNormalizingSlugConverter(
|
|
|
|
new Dictionary<string, string>
|
|
|
|
{
|
|
|
|
["#"] = "-sharp",
|
|
|
|
});
|
2022-07-09 04:52:10 +00:00
|
|
|
|
2022-06-05 19:03:28 +00:00
|
|
|
var expected = new List<string>();
|
|
|
|
var actual = new List<string>();
|
|
|
|
|
|
|
|
this.Test(slug, expected, actual, "One", "one");
|
|
|
|
this.Test(slug, expected, actual, "Two-Words", "two-words");
|
|
|
|
this.Test(slug, expected, actual, "Rutejìmo", "rutejimo");
|
|
|
|
this.Test(slug, expected, actual, "C#", "c-sharp");
|
|
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
}
|
|
|
|
|
2022-07-09 04:52:10 +00:00
|
|
|
private void Test(
|
|
|
|
ISlugConverter slug,
|
|
|
|
List<string> expected,
|
|
|
|
List<string> actual,
|
|
|
|
string input,
|
|
|
|
string output)
|
2022-06-05 19:03:28 +00:00
|
|
|
{
|
|
|
|
expected.Add(output);
|
|
|
|
actual.Add(slug.ToSlug(input));
|
|
|
|
}
|
|
|
|
}
|