当前位置: 首页>>代码示例>>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;未经允许,请勿转载。