public void Initialize()
        {
            // 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(SettingsForTests.GetDefault())
                      .WithConfig(CleanStringType.FileName, new DefaultShortStringHelper.Config
            {
                //PreFilter = ClearFileChars, // done in IsTerm
                IsTerm     = (c, leading) => (char.IsLetterOrDigit(c) || c == '_') && DefaultShortStringHelper.IsValidFileNameChar(c),
                StringType = CleanStringType.LowerCase | CleanStringType.Ascii,
                Separator  = '-'
            })
                      .WithConfig(CleanStringType.UrlSegment, new DefaultShortStringHelper.Config
            {
                PreFilter  = StripQuotes,
                IsTerm     = (c, leading) => char.IsLetterOrDigit(c) || c == '_',
                StringType = CleanStringType.LowerCase | CleanStringType.Ascii,
                Separator  = '-'
            })
                      .WithConfig(new CultureInfo("fr-FR"), CleanStringType.UrlSegment, new DefaultShortStringHelper.Config
            {
                PreFilter  = FilterFrenchElisions,
                IsTerm     = (c, leading) => leading ? char.IsLetter(c) : (char.IsLetterOrDigit(c) || c == '_'),
                StringType = CleanStringType.LowerCase | CleanStringType.Ascii,
                Separator  = '-'
            })
                      .WithConfig(CleanStringType.Alias, new DefaultShortStringHelper.Config
            {
                PreFilter  = StripQuotes,
                IsTerm     = (c, leading) => leading ? char.IsLetter(c) : char.IsLetterOrDigit(c),
                StringType = CleanStringType.UmbracoCase | CleanStringType.Ascii
            })
                      .WithConfig(new CultureInfo("fr-FR"), CleanStringType.Alias, new DefaultShortStringHelper.Config
            {
                PreFilter  = WhiteQuotes,
                IsTerm     = (c, leading) => leading ? char.IsLetter(c) : char.IsLetterOrDigit(c),
                StringType = CleanStringType.UmbracoCase | CleanStringType.Ascii
            })
                      .WithConfig(CleanStringType.ConvertCase, new DefaultShortStringHelper.Config
            {
                PreFilter         = null,
                IsTerm            = (c, leading) => char.IsLetterOrDigit(c) || c == '_', // letter, digit or underscore
                StringType        = CleanStringType.Ascii,
                BreakTermsOnUpper = true
            });

            ShortStringHelperResolver.Reset();
            ShortStringHelperResolver.Current = new ShortStringHelperResolver(_helper);
            Resolution.Freeze();
        }
        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();
        }
 public void TearDown()
 {
     ShortStringHelperResolver.Reset();
 }
 public void Setup()
 {
     ShortStringHelperResolver.Reset();
     ShortStringHelperResolver.Current = new ShortStringHelperResolver(new MockShortStringHelper());
     Resolution.Freeze();
 }
 public void Setup()
 {
     ShortStringHelperResolver.Reset();
 }
Example #6
0
 public void TestTearDown()
 {
     Thread.CurrentThread.CurrentCulture = _savedCulture;
     ShortStringHelperResolver.Reset();
 }