26 lines
No EOL
874 B
C#
26 lines
No EOL
874 B
C#
using IdentityShroud.Core.Helpers;
|
|
|
|
namespace IdentityShroud.Core.Tests.Helpers;
|
|
|
|
public class SlugHelperTests
|
|
{
|
|
[Theory]
|
|
[InlineData("", 40, "")]
|
|
[InlineData("test", 40, "test")]
|
|
[InlineData("Test", 40, "test")]
|
|
[InlineData("tést", 40, "test")]
|
|
[InlineData("foo_bar", 40, "foo-bar")]
|
|
[InlineData("foo bar", 40, "foo-bar")]
|
|
[InlineData("-foo", 40, "foo")]
|
|
[InlineData("foo-", 40, "foo")]
|
|
[InlineData("_foo", 40, "foo")]
|
|
[InlineData("foo_", 40, "foo")]
|
|
[InlineData("slug_would_be_too_long", 16, "slug-woul-frYeRw")] // not at word boundary
|
|
[InlineData("slug_would_be_too_long", 18, "slug-would-frYeRw")] // at word boundary
|
|
public void Test(string input, int max_length, string expected)
|
|
{
|
|
string result = SlugHelper.GenerateSlug(input, max_length);
|
|
|
|
Assert.Equal(expected, result);
|
|
}
|
|
} |