public void ConvertTitleToSlug_WithDotSeparator_UsesDot() { //arrange var config = new NameValueCollection(); config.Add("limitWordCount", "10"); config.Add("separatingCharacter", "."); var settings = new FriendlyUrlSettings(config); var generator = new SlugGenerator(settings); var entry = new Entry(PostType.BlogPost) {Title = "this is a test"}; //act string slug = generator.GetSlugFromTitle(entry); //act Assert.AreEqual("this.is.a.test", slug); }
public void ConvertTitleToSlug_UsingDash_NormalizesDashes() { //arrange var config = new NameValueCollection(); config.Add("limitWordCount", "10"); config.Add("separatingCharacter", "-"); var settings = new FriendlyUrlSettings(config); var generator = new SlugGenerator(settings); var entry = new Entry(PostType.BlogPost) {Title = "-this - is - a - test-"}; //act string slug = generator.GetSlugFromTitle(entry); //act Assert.AreEqual("this-is-a-test", slug); }
public void ConvertTitleToSlug_WithTitleEndingInPeriod_RemovesTrailingPeriod() { //arrange var config = new NameValueCollection(); config.Add("limitWordCount", "10"); config.Add("separatingCharacter", "-"); var settings = new FriendlyUrlSettings(config); var generator = new SlugGenerator(settings); var entry = new Entry(PostType.BlogPost) {Title = "a test."}; //act string slug = generator.GetSlugFromTitle(entry); //act Assert.AreEqual("a-test", slug); }
public void ConvertTitleToSlug_WithTextTransformToUpperCase_TransformsUrlToUpperCase() { //arrange var config = new NameValueCollection(); config.Add("limitWordCount", "10"); config.Add("separatingCharacter", "."); config.Add("TextTransform", "UpperCase"); var settings = new FriendlyUrlSettings(config); var generator = new SlugGenerator(settings); var entry = new Entry(PostType.BlogPost) {Title = "this is a test"}; //act string slug = generator.GetSlugFromTitle(entry); //act Assert.AreEqual("THIS.IS.A.TEST", slug); }
public void ConvertTitleToSlug_WithNullCharacterDelimiterAndSpacesInTitle_RemovesSpacesAndPascalCasesTitle() { //arrange var config = new NameValueCollection(); config.Add("limitWordCount", "10"); config.Add("separatingCharacter", ""); var settings = new FriendlyUrlSettings(config); var generator = new SlugGenerator(settings); var entry = new Entry(PostType.BlogPost) {Title = " this is a test "}; //act string slug = generator.GetSlugFromTitle(entry); //act Assert.AreEqual("ThisIsATest", slug); }
public void ConvertTitleToSlug_WithMoreWordsThanAllowed_TruncatesRemainingWords() { //arrange var config = new NameValueCollection(); config.Add("limitWordCount", "2"); config.Add("separatingCharacter", "_"); var settings = new FriendlyUrlSettings(config); var generator = new SlugGenerator(settings); var entry = new Entry(PostType.BlogPost) {Title = "this is a test"}; //act string slug = generator.GetSlugFromTitle(entry); //act Assert.AreEqual("this_is", slug); }
public SlugGenerator(FriendlyUrlSettings slugSettings, ObjectProvider repository) { SlugSettings = slugSettings ?? DefaultSettings; Repository = repository; }
public SlugGenerator(FriendlyUrlSettings slugSettings) : this(slugSettings, null) { }