예제 #1
0
        public void FixedFormatDateTests()
        {
            DateTime[] boundaries =
            {
                DateTime.MinValue,
                DateTime.MaxValue,
                new DateTime(1999,  1, 1),                         // Single digit month and day
                new DateTime(1999, 11, 25),                        // two digit month and days
                new DateTime(999,   5, 26),                        // three digit year
                new DateTime(2200, 10, 4),                         // two digit month, one digit day
            };

            foreach (var date in boundaries)
            {
                Assert.AreEqual(
                    date.ToString("MM\\/dd\\/yyyy"),
                    TextFormatter.FormatFixedUSDate(date),
                    string.Format("Date formats differed using the US format for date: {0}.", date));
            }

            foreach (var date in boundaries)
            {
                Assert.AreEqual(
                    date.ToString("yyyy-MM-dd"),
                    TextFormatter.FormatFixedIsoDate(date),
                    string.Format("Date formats differed using the ISO format for date: {0}.", date));
            }
        }