ToFourDigitYear() public method

public ToFourDigitYear ( int year ) : int
year int
return int
 public void PosTest2()
 {
     System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
     Random rand = new Random(-55);
     int year = rand.Next(tbc.GetYear(tbc.MinSupportedDateTime), tbc.GetYear(tbc.MaxSupportedDateTime));
     Assert.Equal(year, tbc.ToFourDigitYear(year));
 }
 public void PosTest4()
 {
     System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
     tbc.TwoDigitYearMax = 2029;
     int year = 0;
     int expectedYear = 2000;
     Assert.Equal(expectedYear, tbc.ToFourDigitYear(year));
 }
 public void NegTest1()
 {
     System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
     int year = 10000 + 543;
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         tbc.ToFourDigitYear(year);
     });
 }
 public void PosTest1()
 {
     System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
     tbc.TwoDigitYearMax = 2029;
     Random rand = new Random(-55);
     int year = rand.Next(1, 99);
     int expertedYear;
     if (year > 29)
     {
         expertedYear = year + 1900;
     }
     else
     {
         expertedYear = year + 2000;
     }
     Assert.Equal(expertedYear, tbc.ToFourDigitYear(year));
 }
Esempio n. 5
0
	public void TestToFourDigitYear2 ()
	{
		GregorianCalendar gc = new GregorianCalendar ();
		Assert.AreEqual (2029, gc.ToFourDigitYear (29), "#1-1");
		Assert.AreEqual (1930, gc.ToFourDigitYear (30), "#1-2");
		Assert.AreEqual (2029, gc.ToFourDigitYear (2029), "#1-3");
		Assert.AreEqual (2030, gc.ToFourDigitYear (2030), "#1-4");

		HebrewCalendar hbc = new HebrewCalendar ();
		Assert.AreEqual (5790, hbc.ToFourDigitYear (90), "#2-1");
		Assert.AreEqual (5691, hbc.ToFourDigitYear (91), "#2-2");
		Assert.AreEqual (5790, hbc.ToFourDigitYear (5790), "#2-3");
		Assert.AreEqual (5691, hbc.ToFourDigitYear (5691), "#2-4");
		Assert.AreEqual (5999, hbc.ToFourDigitYear (5999), "#2-5");
		// LAMESPEC: .NET fails to throw an exception unlike documented
		/*
		try {
			hbc.ToFourDigitYear (6000);
			Assert.Fail ("#2-6");
		} catch (ArgumentOutOfRangeException) {
		}
		*/

		ThaiBuddhistCalendar tc = new ThaiBuddhistCalendar ();
		Assert.AreEqual (2572, tc.ToFourDigitYear (72), "#3-1");
		Assert.AreEqual (2473, tc.ToFourDigitYear (73), "#3-2");
		Assert.AreEqual (2572, tc.ToFourDigitYear (2572), "#3-3");
		Assert.AreEqual (2573, tc.ToFourDigitYear (2573), "#3-4");
		Assert.AreEqual (9999, tc.ToFourDigitYear (9999), "#3-5");
		// LAMESPEC: .NET fails to throw an exception unlike documented
		/*
		try {
			tc.ToFourDigitYear (10000);
			Assert.Fail ("#3-6");
		} catch (ArgumentOutOfRangeException) {
		}
		*/

		KoreanCalendar kc = new KoreanCalendar ();
		Assert.AreEqual (4362, kc.ToFourDigitYear (62), "#4-1");
		Assert.AreEqual (4263, kc.ToFourDigitYear (63), "#4-2");
		Assert.AreEqual (4362, kc.ToFourDigitYear (4362), "#4-3");
		Assert.AreEqual (4363, kc.ToFourDigitYear (4363), "#4-4");
	}
 public void PosTest3()
 {
     System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
     int year = 9999 + 543;
     Assert.Equal(year, tbc.ToFourDigitYear(year));
 }