public static string GenerateSlug_3(this string phrase) { var slugity = new Slugity(); string slug = slugity.GenerateSlug(phrase); return(slug); }
public static ScriptServiceSchema Default(ScriptService service) { return(new ScriptServiceSchema() { AccessName = _slugity.GenerateSlug(service.Name) }); }
private void HtmlShouldBeStripped() { var slugity = new Slugity(); string before = "<p>How to strip <a href=\"http://www.google.co.uk\" target=\"_blank\">html</a> from a title for <span style=\"font-weight: bold;\">seo</span> purposes</p>"; string after = "how-to-strip-html-from-a-title-for-seo-purposes"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ExtraSpacesShouldBeRemoved() { var slugity = new Slugity(); string before = "How to remove lots of spaces"; string after = "how-to-remove-lots-of-spaces"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void StopWordsShouldBeDisabled() { var slugity = new Slugity(); string before = "THIS AND THAT SHOULD BE LOWERCASE AND STOP WORDS DISABLED"; string after = "this-and-that-should-be-lowercase-and-stop-words-disabled"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldHaveHyphenForSeparator() { var slugity = new Slugity(); string before = "Text should be separated by hyphens"; string after = "text-should-be-separated-by-hyphens"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldBeLowerCase() { var customConfigration = new CustomSlugityConfig(); var slugity = new Slugity(customConfigration); string before = "THIS SHOULD BE LOWERCASE"; string after = "this should be lowercase"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldNotTrimSlugIfMaxLengthIsNull() { var configuration = new SlugityConfig { MaxLength = null }; var slugity = new Slugity(configuration); string before = "This should not be trimmed"; string after = "this-should-not-be-trimmed"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldNotTruncateWord() { var configuration = new SlugityConfig { MaxLength = 10 }; var slugity = new Slugity(configuration); string before = "The word hippo should not be truncated"; string after = "the-word-hippo"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldTruncateTrailingSeparator() { var configuration = new SlugityConfig { MaxLength = 34 }; var slugity = new Slugity(configuration); string before = "Test to see if the next separator gets truncated"; string after = "test-to-see-if-the-next-separator"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldBeSeparatedByUnderscores() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '_' }; var slugity = new Slugity(configuration); string before = "this should be lowercase"; string after = "this_should_be_lowercase"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldStripStopWords() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '-', StripStopWords = true }; var slugity = new Slugity(configuration); string before = "This then that should be stripped"; string after = "this-should-be-stripped"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldSeparateStrings() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '-' }; var slugity = new Slugity(configuration); string before = "Spaces should be replaced with chosen string separator"; string after = "spaces-should-be-replaced-with-chosen-string-separator"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldBeUpperCase() { var configuration = new SlugityConfig { TextCase = TextCase.UpperCase, StringSeparator = '-' }; var slugity = new Slugity(configuration); string before = "this should BE UPPERCASE"; string after = "THIS-SHOULD-BE-UPPERCASE"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldTrimAdditionalSpaces() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = ' ' }; var slugity = new Slugity(configuration); string before = "Additional spaces should be trimmed"; string after = "additional spaces should be trimmed"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldBeLowerCase() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '-' }; var slugity = new Slugity(configuration); string before = "THIS SHOULD BE LOWERCASE"; string after = "this-should-be-lowercase"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldBeCamalCase() { var configuration = new SlugityConfig { TextCase = TextCase.CamalCase, StringSeparator = '-' }; var slugity = new Slugity(configuration); string before = "this should BE CAMAL CASE"; string after = "This-Should-Be-Camal-Case"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldCleanString() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '-' }; var slugity = new Slugity(configuration); string before = "This should clear the text, ok?"; string after = "this-should-clear-the-text-ok"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldCleanString2() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '-' }; var slugity = new Slugity(configuration); string before = "Clean & tidy strings, this***."; string after = "clean-tidy-strings-this"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldLeaveStopWords() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '-', StripStopWords = false, }; var slugity = new Slugity(configuration); // Broken string before = "This then that should not be stripped"; string after = "this-then-that-should-not-be-stripped"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldCleanStrings3() { var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '-' }; configuration.ReplacementCharacters.Add("remain", "be left behind"); var slugity = new Slugity(configuration); string before = "text !\"£$%^&*(),>/#'; should remain"; string after = "text-should-be-left-behind"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldReplaceCharacters() { var configuration = new SlugityConfig { TextCase = TextCase.Ignore, StringSeparator = ' ' }; configuration.ReplacementCharacters.Add("Hello", "Goodbye"); var slugity = new Slugity(configuration); string before = "Hello World"; string after = "Goodbye World"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldReplaceMultipleWords() { var characters = new CharacterReplacement(); characters.Add("Hello World", "Goodbye Planet"); var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '-', ReplacementCharacters = characters }; var slugity = new Slugity(configuration); string before = "Hello World"; string after = "goodbye-planet"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldReplaceSeparatorIfSameChar() { var characters = new CharacterReplacement(); characters.Add("_", ""); var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '_', ReplacementCharacters = characters }; var slugity = new Slugity(configuration); string before = "Hello_World"; string after = "helloworld"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }
private void ShouldBeAbleToAddThenReplaceWords() { var characters = new CharacterReplacement(); characters.Add("Hello", "Goodbye"); var configuration = new SlugityConfig { TextCase = TextCase.LowerCase, StringSeparator = '_', ReplacementCharacters = characters }; characters.AddOrReplace("Goodbye", "Hello"); var slugity = new Slugity(configuration); string before = "Hello World"; string after = "hello_world"; string result = slugity.GenerateSlug(before); result.ShouldBe(after); }