2020-12-20 08:36:11 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
|
|
|
using Microsoft.Extensions.Options;
|
2020-09-22 15:59:37 +02:00
|
|
|
using NUnit.Framework;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
|
|
|
using Umbraco.Cms.Core.Strings;
|
|
|
|
|
using Umbraco.Extensions;
|
2015-01-14 12:09:30 +11:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.ShortStringHelper
|
2015-01-14 12:09:30 +11:00
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-09-22 15:59:37 +02:00
|
|
|
public class CmsHelperCasingTests
|
2015-01-14 12:09:30 +11:00
|
|
|
{
|
2020-09-22 15:59:37 +02:00
|
|
|
private IShortStringHelper ShortStringHelper => new DefaultShortStringHelper(Options.Create(new RequestHandlerSettings()));
|
|
|
|
|
|
2015-01-14 12:09:30 +11:00
|
|
|
[TestCase("thisIsTheEnd", "This Is The End")]
|
|
|
|
|
[TestCase("th", "Th")]
|
|
|
|
|
[TestCase("t", "t")]
|
|
|
|
|
[TestCase("thisis", "Thisis")]
|
|
|
|
|
[TestCase("ThisIsTheEnd", "This Is The End")]
|
2020-12-20 08:36:11 +01:00
|
|
|
//// [TestCase("WhoIsNumber6InTheVillage", "Who Is Number6In The Village")] // note the issue with Number6In
|
2015-01-14 12:09:30 +11:00
|
|
|
[TestCase("WhoIsNumber6InTheVillage", "Who Is Number6 In The Village")] // now fixed since DefaultShortStringHelper is the default
|
|
|
|
|
public void SpaceCamelCasing(string input, string expected)
|
|
|
|
|
{
|
2019-12-18 18:55:00 +01:00
|
|
|
var output = input.SpaceCamelCasing(ShortStringHelper);
|
2015-01-14 12:09:30 +11:00
|
|
|
Assert.AreEqual(expected, output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase("thisIsTheEnd", "This Is The End")]
|
|
|
|
|
[TestCase("th", "Th")]
|
|
|
|
|
[TestCase("t", "t")]
|
|
|
|
|
[TestCase("thisis", "Thisis")]
|
|
|
|
|
[TestCase("ThisIsTheEnd", "This Is The End")]
|
|
|
|
|
[TestCase("WhoIsNumber6InTheVillage", "Who Is Number6 In The Village")] // issue is fixed
|
|
|
|
|
public void CompatibleDefaultReplacement(string input, string expected)
|
|
|
|
|
{
|
2020-09-22 15:59:37 +02:00
|
|
|
var output = input.Length < 2 ? input : ShortStringHelper.SplitPascalCasing(input, ' ').ToFirstUpperInvariant();
|
2015-01-14 12:09:30 +11:00
|
|
|
Assert.AreEqual(expected, output);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|