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.GetMonthsInYear(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.GetMonthsInYear(y, myCal.Eras[i]));
            }
            Console.WriteLine();
        }
    }
 public void GetMonthsInYear(int year)
 {
     TaiwanCalendar calendar = new TaiwanCalendar();
     Assert.Equal(12, calendar.GetMonthsInYear(year));
     Assert.Equal(12, calendar.GetMonthsInYear(year, 0));
     Assert.Equal(12, calendar.GetMonthsInYear(year, 1));
 }
Exemple #3
0
        public void GetMonthsInYear(int year)
        {
            TaiwanCalendar calendar = new TaiwanCalendar();

            Assert.Equal(12, calendar.GetMonthsInYear(year));
            Assert.Equal(12, calendar.GetMonthsInYear(year, 0));
            Assert.Equal(12, calendar.GetMonthsInYear(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.GetMonthsInYear(year, era);
            });
        }
        public void PosTest3()
        {
            System.Globalization.Calendar tc = new TaiwanCalendar();
            DateTime dt   = tc.MaxSupportedDateTime;
            int      year = dt.Year - 1911;
            int      era;

            for (int i = 0; i < tc.Eras.Length; i++)
            {
                era = tc.Eras[i];
                Assert.Equal(_months_IN_YEAR, tc.GetMonthsInYear(year, era));
            }
        }
        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;

            for (int i = 0; i < tc.Eras.Length; i++)
            {
                era = tc.Eras[i];
                Assert.Equal(_months_IN_YEAR, tc.GetMonthsInYear(year, era));
            }
        }
Exemple #7
0
    public static void Main()
    {
        // Creates and initializes a TaiwanCalendar.
        TaiwanCalendar myCal = new TaiwanCalendar();

        // Checks all the months in five years in the current era.
        int iMonthsInYear;

        for (int y = 90; y <= 94; y++)
        {
            Console.Write("{0}:\t", y);
            iMonthsInYear = myCal.GetMonthsInYear(y, TaiwanCalendar.CurrentEra);
            for (int m = 1; m <= iMonthsInYear; m++)
            {
                Console.Write("\t{0}", myCal.IsLeapMonth(y, m, TaiwanCalendar.CurrentEra));
            }
            Console.WriteLine();
        }
    }