flush
[mcs.git] / class / System.Core / Test / System / TimeZoneInfo.TransitionTimeTest.cs
blob8dd8263fd223fb82fdb01679173c6c948460538e
2 using System;
3 using NUnit.Framework;
5 #if NET_2_0
6 namespace MonoTests.System
8 public class TimeZoneInfo_TransitionTimeTest
9 {
10 [TestFixture]
11 public class CreateFixedDateRuleExceptions
13 [Test]
14 [ExpectedException (typeof (ArgumentException))]
15 public void DateHasNonDefaultComponent ()
17 TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 10, 2, 0, 0), 3, 15);
20 [Test]
21 [ExpectedException (typeof (ArgumentException))]
22 public void KindNotUnspecified()
24 TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0, DateTimeKind.Utc), 3, 15);
27 [Test]
28 [ExpectedException (typeof (ArgumentException))]
29 public void DateNotInMilliSeconds ()
31 TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (50), 3, 15);
34 [Test]
35 [ExpectedException (typeof (ArgumentOutOfRangeException))]
36 public void MonthOutOfRange ()
38 TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0), 13, 15);
41 [Test]
42 [ExpectedException (typeof (ArgumentOutOfRangeException))]
43 public void DayOutOfRange ()
45 TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, -2);
49 [TestFixture]
50 public class CreateFloatingDateRuleExceptions
52 [Test]
53 [ExpectedException (typeof (ArgumentException))]
54 public void DateHasNonDefaultComponent ()
56 TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 10, 2, 0, 0), 3, 4, DayOfWeek.Sunday);
59 [Test]
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);
66 [Test]
67 [ExpectedException (typeof (ArgumentException))]
68 public void DateNotInSeconds ()
70 TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (50), 3, 4, DayOfWeek.Sunday);
73 [Test]
74 [ExpectedException (typeof (ArgumentOutOfRangeException))]
75 public void MonthOutOfRange ()
77 TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 13, 4, DayOfWeek.Sunday);
80 [Test]
81 [ExpectedException (typeof (ArgumentOutOfRangeException))]
82 public void WeekOutOfRange ()
84 TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, -2, DayOfWeek.Sunday);
87 [Test]
88 [ExpectedException (typeof (ArgumentOutOfRangeException))]
89 public void DayOfWeekOutOfRange ()
91 TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, 4, (DayOfWeek)12);
95 [TestFixture]
96 public class NonExceptional {
98 [Test]
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");
112 #endif