'--------------------------------------------------------------------
' Test case of DateTime Class
'--------------------------------------------------------------------

Namespace DateTimeTest

Imports System

Sub TestMain()

	UnitTest("DateTime.Now" + " " + DateTime.Now.ToString(), True)

	UnitTest("DateTime.IsLeapYear - 2000", DateTime.IsLeapYear(2000) = True)
	UnitTest("DateTime.IsLeapYear - 2001", DateTime.IsLeapYear(2001) = False)
	UnitTest("DateTime.IsLeapYear - 2004", DateTime.IsLeapYear(2004) = True)
	UnitTest("DateTime.IsLeapYear - 2100", DateTime.IsLeapYear(2100) = False)

	Dim testDateTime = New DateTime(2008, 12, 31, 23, 59, 59, 999)
	UnitTest("DateTime.Millisecond", testDateTime.Millisecond = 999)
	UnitTest("DateTime.Second", testDateTime.Second = 59)
	UnitTest("DateTime.Minute", testDateTime.Minute = 59)
	UnitTest("DateTime.Hour", testDateTime.Hour = 23)
	UnitTest("DateTime.Day", testDateTime.Day = 31)
	UnitTest("DateTime.Month", testDateTime.Month = 12)
	UnitTest("DateTime.Year", testDateTime.Year = 2008)
	UnitTest("DateTime.DayOfWeek", testDateTime.DayOfWeek = 3)'DayOfWeek.Wednesday)
	UnitTest("DateTime.Kind", testDateTime.Kind = DateTimeKind.Unspecified)
	UnitTest("DateTime.DayOfYear", testDateTime.DayOfYear = 366)

	UnitTest("DateTime.Equals", testDateTime.Equals(testDateTime))
	UnitTest("DateTime.Compare (Case1)", DateTime.Compare(New DateTime(2000, 1, 2), New DateTime(2000, 1, 2)) = 0)
	UnitTest("DateTime.Compare (Case2)", DateTime.Compare(New DateTime(2000, 1, 2), New DateTime(2000, 1, 1)) > 0)
	UnitTest("DateTime.Compare (Case3)", DateTime.Compare(New DateTime(2000, 1, 1), New DateTime(2000, 1, 2)) < 0)

	Dim testDate = testDateTime.Date
	UnitTest("DateTime.Date", DateTime.Compare(testDate, New DateTime(2008, 12, 31)) = 0)
	UnitTest("DateTime.Add", testDate.Add(TimeSpan.FromTicks(863999990000)) = testDateTime)
	UnitTest("DateTime.AddTicks", testDate.AddTicks(863999990000) = testDateTime)
	UnitTest("DateTime.AddMilliseconds", testDate.AddMilliseconds(86399999) = testDateTime)
	UnitTest("DateTime.AddSeconds", testDate.AddSeconds(86399.999) = testDateTime)
	UnitTest("DateTime.AddMinutes", DateTime.Compare(testDate.AddMinutes(1), New DateTime(2008, 12, 31, 0, 1, 0)) = 0)
	UnitTest("DateTime.AddHours", DateTime.Compare(testDate.AddHours(1), New DateTime(2008, 12, 31, 1, 0, 0)) = 0)
	UnitTest("DateTime.AddDays", DateTime.Compare(testDate.AddDays(1), New DateTime(2009, 1, 1)) = 0)
	UnitTest("DateTime.AddYears", DateTime.Compare(testDate.AddYears(1), New DateTime(2009, 12, 31)) = 0)
End Sub

End Namespace

DateTimeTest.TestMain()
