Ensures cultures set on content are correctly cased (#19290)
* Ensures cultures set on content are correctly cased and verifies with integration tests. * Improved test comments. * Move culture casing check into an extension method and use from content service. * Deduplicated test code and added more test cases * Only run invalid culture codes test on Windows --------- Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -395,4 +396,17 @@ public class StringExtensionsTests
|
||||
var ids = input.GetIdsFromPathReversed();
|
||||
Assert.AreEqual(expected, string.Join(",", ids));
|
||||
}
|
||||
|
||||
[TestCase(null, null)]
|
||||
[TestCase("", "")]
|
||||
[TestCase("*", "*")]
|
||||
[TestCase("en", "en")]
|
||||
[TestCase("EN", "en")]
|
||||
[TestCase("en-US", "en-US")]
|
||||
[TestCase("en-gb", "en-GB")]
|
||||
public void EnsureCultureCode_ReturnsExpectedResult(string? culture, string? expected) => Assert.AreEqual(expected, culture.EnsureCultureCode());
|
||||
|
||||
[Test]
|
||||
[Platform(Include = "Win")]
|
||||
public void EnsureCultureCode_ThrowsOnUnrecognisedCode() => Assert.Throws<CultureNotFoundException>(() => "xxx-xxx".EnsureCultureCode());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user