TimeZoneInfo.TransitionTimeTest.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using NUnit.Framework;
  3. #if NET_2_0
  4. namespace MonoTests.System
  5. {
  6. public class TimeZoneInfo_TransitionTimeTest
  7. {
  8. [TestFixture]
  9. public class CreateFixedDateRuleExceptions
  10. {
  11. [Test]
  12. [ExpectedException (typeof (ArgumentException))]
  13. public void DateHasNonDefaultComponent ()
  14. {
  15. TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 10, 2, 0, 0), 3, 15);
  16. }
  17. [Test]
  18. [ExpectedException (typeof (ArgumentException))]
  19. public void KindNotUnspecified()
  20. {
  21. TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0, DateTimeKind.Utc), 3, 15);
  22. }
  23. [Test]
  24. [ExpectedException (typeof (ArgumentException))]
  25. public void DateNotInSeconds ()
  26. {
  27. TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0, 77), 3, 15);
  28. }
  29. [Test]
  30. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  31. public void MonthOutOfRange ()
  32. {
  33. TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0), 13, 15);
  34. }
  35. [Test]
  36. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  37. public void DayOutOfRange ()
  38. {
  39. TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, -2);
  40. }
  41. }
  42. [TestFixture]
  43. public class CreateFloatingDateRuleExceptions
  44. {
  45. [Test]
  46. [ExpectedException (typeof (ArgumentException))]
  47. public void DateHasNonDefaultComponent ()
  48. {
  49. TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 10, 2, 0, 0), 3, 4, DayOfWeek.Sunday);
  50. }
  51. [Test]
  52. [ExpectedException (typeof (ArgumentException))]
  53. public void KindNotUnspecified()
  54. {
  55. TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0, DateTimeKind.Utc), 3, 4, DayOfWeek.Sunday);
  56. }
  57. [Test]
  58. [ExpectedException (typeof (ArgumentException))]
  59. public void DateNotInSeconds ()
  60. {
  61. TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0, 77), 3, 4, DayOfWeek.Sunday);
  62. }
  63. [Test]
  64. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  65. public void MonthOutOfRange ()
  66. {
  67. TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 13, 4, DayOfWeek.Sunday);
  68. }
  69. [Test]
  70. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  71. public void WeekOutOfRange ()
  72. {
  73. TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, -2, DayOfWeek.Sunday);
  74. }
  75. [Test]
  76. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  77. public void DayOfWeekOutOfRange ()
  78. {
  79. TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 0, 0), 3, 4, (DayOfWeek)12);
  80. }
  81. }
  82. }
  83. }
  84. #endif