public static void Main()
    {
        // Creates and initializes a TaiwanCalendar.
        TaiwanCalendar myCal = new TaiwanCalendar();

        // Displays the header.
        Console.Write("YEAR\t");
        for (int y = 90; y <= 94; y++)
        {
            Console.Write("\t{0}", y);
        }
        Console.WriteLine();

        // Displays the value of the CurrentEra property.
        Console.Write("CurrentEra:");
        for (int y = 90; y <= 94; y++)
        {
            Console.Write("\t{0}", myCal.GetDaysInYear(y, TaiwanCalendar.CurrentEra));
        }
        Console.WriteLine();

        // Displays the values in the Eras property.
        for (int i = 0; i < myCal.Eras.Length; i++)
        {
            Console.Write("Era {0}:\t", myCal.Eras[i]);
            for (int y = 90; y <= 94; y++)
            {
                Console.Write("\t{0}", myCal.GetDaysInYear(y, myCal.Eras[i]));
            }
            Console.WriteLine();
        }
    }
 public void GetDaysInYear(int year)
 {
     TaiwanCalendar calendar = new TaiwanCalendar();
     int expected = calendar.IsLeapYear(year) ? 366 : 365;
     Assert.Equal(expected, calendar.GetDaysInYear(year));
     Assert.Equal(expected, calendar.GetDaysInYear(year, 0));
     Assert.Equal(expected, calendar.GetDaysInYear(year, 1));
 }
        public void GetDaysInYear(int year)
        {
            TaiwanCalendar calendar = new TaiwanCalendar();
            int            expected = calendar.IsLeapYear(year) ? 366 : 365;

            Assert.Equal(expected, calendar.GetDaysInYear(year));
            Assert.Equal(expected, calendar.GetDaysInYear(year, 0));
            Assert.Equal(expected, calendar.GetDaysInYear(year, 1));
        }
        public void NegTest2()
        {
            System.Globalization.Calendar tc = new TaiwanCalendar();
            Random rand = new Random(-55);
            int    year = tc.MinSupportedDateTime.Year - rand.Next(1, Int32.MaxValue);
            int    era  = Calendar.CurrentEra;

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                tc.GetDaysInYear(year, era);
            });
        }
        public void PosTest4()
        {
            System.Globalization.Calendar tc = new TaiwanCalendar();
            DateTime dt   = new DateTime(2000, 12, 31);
            int      year = dt.Year;
            int      era;
            int      actualDays;

            if (tc.IsLeapYear(year))
            {
                actualDays = 366;
            }
            else
            {
                actualDays = 365;
            }

            for (int i = 0; i < tc.Eras.Length; i++)
            {
                era = tc.Eras[i];
                Assert.Equal(tc.GetDaysInYear(year, era), actualDays);
            }
        }
        public void PosTest1()
        {
            System.Globalization.Calendar tc = new TaiwanCalendar();
            Random rand = new Random(-55);
            int    year = rand.Next(tc.MinSupportedDateTime.Year, tc.MaxSupportedDateTime.Year - 1911);
            int    era;
            int    actualDays;

            if (tc.IsLeapYear(year))
            {
                actualDays = 366;
            }
            else
            {
                actualDays = 365;
            }

            for (int i = 0; i < tc.Eras.Length; i++)
            {
                era = tc.Eras[i];
                Assert.Equal(tc.GetDaysInYear(year, era), actualDays);
            }
        }