本文整理匯總了C#中System.Globalization.ThaiBuddhistCalendar.ToFourDigitYear方法的典型用法代碼示例。如果您正苦於以下問題:C# ThaiBuddhistCalendar.ToFourDigitYear方法的具體用法?C# ThaiBuddhistCalendar.ToFourDigitYear怎麽用?C# ThaiBuddhistCalendar.ToFourDigitYear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Globalization.ThaiBuddhistCalendar
的用法示例。
在下文中一共展示了ThaiBuddhistCalendar.ToFourDigitYear方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PosTest2
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));
}
示例2: PosTest4
public void PosTest4()
{
System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
tbc.TwoDigitYearMax = 2029;
int year = 0;
int expectedYear = 2000;
Assert.Equal(expectedYear, tbc.ToFourDigitYear(year));
}
示例3: NegTest1
public void NegTest1()
{
System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
int year = 10000 + 543;
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
tbc.ToFourDigitYear(year);
});
}
示例4: PosTest1
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));
}
示例5: 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");
}
示例6: PosTest3
public void PosTest3()
{
System.Globalization.Calendar tbc = new ThaiBuddhistCalendar();
int year = 9999 + 543;
Assert.Equal(year, tbc.ToFourDigitYear(year));
}