public void Setup() { // NOTE: it is not possible to configure the helper once it has been assigned // to the resolver and resolution has frozen. but, obviously, it is possible // to configure filters and then to alter these filters after resolution has // frozen. beware, nothing is thread-safe in-there! // NOTE pre-filters runs _before_ Recode takes place // so there still may be utf8 chars even though you want ascii _helper = new DefaultShortStringHelper() .WithConfig(CleanStringType.Url, StripQuotes, allowLeadingDigits: true) .WithConfig(new CultureInfo("fr-FR"), CleanStringType.Url, FilterFrenchElisions, allowLeadingDigits: true) .WithConfig(CleanStringType.Alias, StripQuotes) .WithConfig(new CultureInfo("fr-FR"), CleanStringType.Alias, WhiteQuotes); ShortStringHelperResolver.Reset(); ShortStringHelperResolver.Current = new ShortStringHelperResolver(_helper); Resolution.Freeze(); }
[TestCase("WhoIsNumber6InTheVillage", "Who Is Number6 In The Village")] // issue is fixed public void CompatibleDefaultReplacement(string input, string expected) { var helper = new DefaultShortStringHelper(); var output = input.Length < 2 ? input : helper.SplitPascalCasing(input, ' ').ToFirstUpperInvariant(); Assert.AreEqual(expected, output); }
public void CleanStringWithUnderscore(string input, string expected, bool allowUnderscoreInTerm) { var helper = new DefaultShortStringHelper() .WithConfig(allowUnderscoreInTerm: allowUnderscoreInTerm); var output = helper.CleanString(input, CleanStringType.Alias | CleanStringType.Ascii | CleanStringType.CamelCase); Assert.AreEqual(expected, output); }