6 namespace MonoTests
.System
8 public class TimeZoneInfo_TransitionTimeTest
11 public class CreateFixedDateRuleExceptions
14 [ExpectedException (typeof (ArgumentException
))]
15 public void DateHasNonDefaultComponent ()
17 TimeZoneInfo
.TransitionTime
.CreateFixedDateRule (new DateTime (1, 1, 10, 2, 0, 0), 3, 15);
21 [ExpectedException (typeof (ArgumentException
))]
22 public void KindNotUnspecified()
24 TimeZoneInfo
.TransitionTime
.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0, DateTimeKind
.Utc
), 3, 15);
28 [ExpectedException (typeof (ArgumentException
))]
29 public void DateNotInMilliSeconds ()
31 TimeZoneInfo
.TransitionTime
.CreateFixedDateRule (new DateTime (50), 3, 15);
35 [ExpectedException (typeof (ArgumentOutOfRangeException
))]
36 public void MonthOutOfRange ()
38 TimeZoneInfo
.TransitionTime
.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0), 13, 15);
42 [ExpectedException (typeof (ArgumentOutOfRangeException
))]
43 public void DayOutOfRange ()
45 TimeZoneInfo
.TransitionTime
.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, -2);
50 public class CreateFloatingDateRuleExceptions
53 [ExpectedException (typeof (ArgumentException
))]
54 public void DateHasNonDefaultComponent ()
56 TimeZoneInfo
.TransitionTime
.CreateFloatingDateRule (new DateTime (1, 1, 10, 2, 0, 0), 3, 4, DayOfWeek
.Sunday
);
60 [ExpectedException (typeof (ArgumentException
))]
61 public void KindNotUnspecified()
63 TimeZoneInfo
.TransitionTime
.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0, DateTimeKind
.Utc
), 3, 4, DayOfWeek
.Sunday
);
67 [ExpectedException (typeof (ArgumentException
))]
68 public void DateNotInSeconds ()
70 TimeZoneInfo
.TransitionTime
.CreateFloatingDateRule (new DateTime (50), 3, 4, DayOfWeek
.Sunday
);
74 [ExpectedException (typeof (ArgumentOutOfRangeException
))]
75 public void MonthOutOfRange ()
77 TimeZoneInfo
.TransitionTime
.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 13, 4, DayOfWeek
.Sunday
);
81 [ExpectedException (typeof (ArgumentOutOfRangeException
))]
82 public void WeekOutOfRange ()
84 TimeZoneInfo
.TransitionTime
.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, -2, DayOfWeek
.Sunday
);
88 [ExpectedException (typeof (ArgumentOutOfRangeException
))]
89 public void DayOfWeekOutOfRange ()
91 TimeZoneInfo
.TransitionTime
.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, 4, (DayOfWeek
)12);
96 public class NonExceptional
{
99 public void EqualsObject ()
101 DateTime dt
= new DateTime (1, 1, 1, 2, 0, 0, DateTimeKind
.Unspecified
);
102 TimeZoneInfo
.TransitionTime tt1
= TimeZoneInfo
.TransitionTime
.CreateFixedDateRule (dt
, 1, 21);
103 Assert
.IsFalse (tt1
.Equals (null), "null"); // found using Gendarme :)
104 Assert
.IsTrue (tt1
.Equals (tt1
), "self");
105 TimeZoneInfo
.TransitionTime tt2
= TimeZoneInfo
.TransitionTime
.CreateFixedDateRule (dt
, 2, 12);
106 Assert
.IsFalse (tt2
.Equals (tt1
), "1!=2");
107 Assert
.IsFalse (tt1
.Equals (tt2
), "2!=1");