Пример #1
0
        public void DateTimeOD_NormalizeApplicationShortDateFormat_AllCultures()
        {
            bool   isTwoDigitYearTested = false;
            string strYearFormat        = "yyyy";

            foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
            {
                Application.CurrentCulture = culture;
                CultureInfo.DefaultThreadCurrentCulture   = Application.CurrentCulture;
                CultureInfo.DefaultThreadCurrentUICulture = Application.CurrentCulture;
                if (!isTwoDigitYearTested && (Regex.IsMatch(Application.CurrentCulture.DateTimeFormat.ShortDatePattern, "^y{2}[^y]") ||
                                              Regex.IsMatch(Application.CurrentCulture.DateTimeFormat.ShortDatePattern, "[^y]y{2}[^y]") ||
                                              Regex.IsMatch(Application.CurrentCulture.DateTimeFormat.ShortDatePattern, "[^y]y{2}$")))
                {
                    isTwoDigitYearTested = true;
                }
                DateTimeOD.NormalizeApplicationShortDateFormat();
                Assert.IsTrue(Application.CurrentCulture.DateTimeFormat.ShortDatePattern.Contains(strYearFormat));
                Assert.IsTrue(CultureInfo.DefaultThreadCurrentCulture.DateTimeFormat.ShortDatePattern.Contains(strYearFormat));
                Assert.IsTrue(CultureInfo.DefaultThreadCurrentUICulture.DateTimeFormat.ShortDatePattern.Contains(strYearFormat));
            }
            Assert.IsTrue(isTwoDigitYearTested);
        }