public void FormatStringConverterSplitPascalCase() { FormatStringConverter converter = new FormatStringConverter() { SplitPascalCase = true }; Assert.AreEqual("This Is Test", (string)converter.Convert("ThisIsTest", typeof(string), null, null)); Assert.AreEqual("This Is Test", (string)converter.Convert("This Is Test", typeof(string), null, null)); Assert.AreEqual("This Is Test", (string)converter.Convert("This Is Test", typeof(string), null, null)); }
public void FormatStringConverterOutStringCase() { FormatStringConverter converter = new FormatStringConverter() { FormatString = "MMMM" }; string s1 = (string)converter.Convert(DateTime.MinValue, typeof(string), null, null); converter.OutStringCaseFormat = UI.FormatStringConverter.TextCaseFormat.Lower; string s2 = (string)converter.Convert(DateTime.MinValue, typeof(string), null, null); converter.OutStringCaseFormat = UI.FormatStringConverter.TextCaseFormat.Upper; string s3 = (string)converter.Convert(DateTime.MinValue, typeof(string), null, null); Assert.AreNotEqual(s1, s2); Assert.AreNotEqual(s1, s3); Assert.AreEqual(s1.ToLower(), s2); Assert.AreEqual(s1.ToUpper(), s3); }
public void FormatStringConverter() { var savedCulture = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol; try { FormatStringConverter converter = new FormatStringConverter(); converter.FormatString = "C0"; System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol = "#test currency symbol#"; string s = (string)converter.Convert(13, typeof(string), null, System.Globalization.CultureInfo.InvariantCulture.NativeName); Assert.IsTrue(s.Contains("#test currency symbol#")); } finally { System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol = savedCulture; } }
public void FormatStringConverter() { var savedCulture = System.Threading.Thread.CurrentThread.CurrentUICulture; try { FormatStringConverter converter = new FormatStringConverter(); converter.FormatString = "C0"; var changedCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentUICulture.Clone(); changedCulture.NumberFormat.CurrencySymbol = "#test currency symbol#"; System.Threading.Thread.CurrentThread.CurrentUICulture = changedCulture; string s = (string)converter.Convert(13, typeof(string), null, System.Globalization.CultureInfo.InvariantCulture); Assert.IsTrue(s.Contains("#test currency symbol#")); } finally { System.Threading.Thread.CurrentThread.CurrentUICulture = savedCulture; } }