using System.Globalization; using Chronos.Core.Localization; using Chronos.Testing; namespace Chronos.Core.Tests.Localization; /// Switches the process-wide UI language, so nothing else runs meanwhile. [Serial] public sealed class LocTests { [Test] public void FieldSeparatorsHoldDirectionMarksOnlyInRightToLeftLanguages() { var before = Loc.Culture; try { foreach (var culture in new[] { "en", "it" }) { Loc.SetCulture(CultureInfo.GetCultureInfo(culture)); Assert.Equal(" · ", Loc.Separator); Assert.Equal(" · ", Loc.IslandSeparator); } foreach (var culture in new[] { "ar", "he" }) { Loc.SetCulture(CultureInfo.GetCultureInfo(culture)); // A strong right-to-left character on each side: a number after a Latin field stays in its own field. Assert.Equal("\u200F · \u200F", Loc.Separator); // In a left-to-right island, strong left-to-right ones: a number after a time with its "PM" mark stays in its own field. Assert.Equal("\u200E · \u200E", Loc.IslandSeparator); } } finally { Loc.SetCulture(before); } } }