This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/tests/MfGames.Nitride.Slugs.Tests/UnicodeNormalizingSlugConverterTest.cs

65 lines
1.7 KiB
C#

using System.Collections.Generic;
using MfGames.Nitride.Tests;
using Xunit;
using Xunit.Abstractions;
namespace MfGames.Nitride.Slugs.Tests;
/// <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",
});
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);
}
private void Test(
ISlugConverter slug,
List<string> expected,
List<string> actual,
string input,
string output)
{
expected.Add(output);
actual.Add(slug.ToSlug(input));
}
}