當前位置: 首頁>>代碼示例>>C#>>正文


C# KoreanCalendar.ToFourDigitYear方法代碼示例

本文整理匯總了C#中System.Globalization.KoreanCalendar.ToFourDigitYear方法的典型用法代碼示例。如果您正苦於以下問題:C# KoreanCalendar.ToFourDigitYear方法的具體用法?C# KoreanCalendar.ToFourDigitYear怎麽用?C# KoreanCalendar.ToFourDigitYear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Globalization.KoreanCalendar的用法示例。


在下文中一共展示了KoreanCalendar.ToFourDigitYear方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PosTest3

        public void PosTest3()
        {
            System.Globalization.Calendar kC = new KoreanCalendar();
            int twoDigitMax = kC.TwoDigitYearMax;
            int lBound = twoDigitMax - 99;
            int rBound = twoDigitMax;
            int twoDigitYear = _generator.GetInt16(-55) % 100;
            int expectedValue;
            if (twoDigitYear < (lBound % 100))
            {
                expectedValue = (lBound / 100 + 1) * 100 + twoDigitYear;
            }
            else
            {
                expectedValue = (lBound / 100) * 100 + twoDigitYear;
            }

            int actualValue = kC.ToFourDigitYear(twoDigitYear);
            Assert.Equal(expectedValue, actualValue);
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:20,代碼來源:KoreanCalendarToFourDigitYear.cs

示例2: TestToFourDigitYear2

	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");
	}
開發者ID:GirlD,項目名稱:mono,代碼行數:44,代碼來源:CalendarTest.cs

示例3: NegTest1

 public void NegTest1()
 {
     System.Globalization.Calendar kC = new KoreanCalendar();
     int actualValue;
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         actualValue = kC.ToFourDigitYear(100);
     });
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:9,代碼來源:KoreanCalendarToFourDigitYear.cs

示例4: NegTest3

 public void NegTest3()
 {
     System.Globalization.Calendar kC = new KoreanCalendar();
     int actualValue;
     // it stands to reason that if we're looking to throw an exception then it might be a good idea
     // to ensure the value passed into the method is one that will actual cause the exception to be
     // thrown
     // 100-2333  throw exception
     // 2334-12332 no exception
     // 12333 or more throw exception
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         actualValue = kC.ToFourDigitYear(12333);
     });
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:15,代碼來源:KoreanCalendarToFourDigitYear.cs


注:本文中的System.Globalization.KoreanCalendar.ToFourDigitYear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。