Пример #1
0
 public void IsLeapDay(int year, int month, int day, bool expected)
 {
     TaiwanCalendar calendar = new TaiwanCalendar();
     Assert.Equal(expected, calendar.IsLeapDay(year, month, day));
     Assert.Equal(expected, calendar.IsLeapDay(year, month, day, 0));
     Assert.Equal(expected, calendar.IsLeapDay(year, month, day, 1));
 }
Пример #2
0
   public static void Main()  {

      // Creates and initializes a TaiwanCalendar.
      TaiwanCalendar myCal = new TaiwanCalendar();

      // Creates a holder for the last day of the second month (February).
      int iLastDay;

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

      // Checks five years in the current era.
      Console.Write( "CurrentEra:" );
      for ( int y = 90; y <= 94; y++ )  {
         iLastDay = myCal.GetDaysInMonth( y, 2, TaiwanCalendar.CurrentEra );
         Console.Write( "\t{0}", myCal.IsLeapDay( y, 2, iLastDay, TaiwanCalendar.CurrentEra ) );
      }
      Console.WriteLine();

      // Checks five years in each of the eras.
      for ( int i = 0; i < myCal.Eras.Length; i++ )  {
         Console.Write( "Era {0}:\t", myCal.Eras[i] );
         for ( int y = 90; y <= 94; y++ )  {
            iLastDay = myCal.GetDaysInMonth( y, 2, myCal.Eras[i] );
            Console.Write( "\t{0}", myCal.IsLeapDay( y, 2, iLastDay, myCal.Eras[i] ) );
         }
         Console.WriteLine();
      }

   }
        public void IsLeapDay(int year, int month, int day, bool expected)
        {
            TaiwanCalendar calendar = new TaiwanCalendar();

            Assert.Equal(expected, calendar.IsLeapDay(year, month, day));
            Assert.Equal(expected, calendar.IsLeapDay(year, month, day, 0));
            Assert.Equal(expected, calendar.IsLeapDay(year, month, day, 1));
        }
Пример #4
0
        public void NegTest3()
        {
            System.Globalization.Calendar tc = new TaiwanCalendar();
            Random rand  = new Random(-55);
            int    year  = rand.Next(tc.MinSupportedDateTime.Year, tc.MaxSupportedDateTime.Year + 1);
            int    month = rand.Next(12, Int32.MaxValue);
            int    day   = rand.Next(1, 28);
            int    era   = Calendar.CurrentEra;

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                tc.IsLeapDay(year, month, day, era);
            });
        }
Пример #5
0
        public void PosTest2()
        {
            System.Globalization.Calendar tc = new TaiwanCalendar();
            Random rand  = new Random(-55);
            int    year  = 2000 - 1911;
            int    month = 2;
            int    day   = 29;
            int    era;

            for (int i = 0; i < tc.Eras.Length; i++)
            {
                era = tc.Eras[i];
                Assert.True(tc.IsLeapDay(year, month, day, era));
            }
        }
Пример #6
0
        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    month = rand.Next(1, 12);
            int    day   = rand.Next(1, 29);
            int    era;

            for (int i = 0; i < tc.Eras.Length; i++)
            {
                era = tc.Eras[i];
                Assert.False(tc.IsLeapDay(year, month, era));
            }
        }