[corlib] Test TimeZoneInfo.GetDaylightChanges.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Mon, 18 May 2015 16:12:30 +0000 (17:12 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Mon, 18 May 2015 16:12:30 +0000 (17:12 +0100)
Testing TimeZoneInfo.GetDaylightChanges with Australia/Sydney time zone.

mcs/class/corlib/Test/System/TimeZoneInfoTest.cs

index bdce606080e01e90ef49fed05f36b5dfffc472b1..32dbb0f2f735abd8f4e613984d8d1220d4f1c108 100644 (file)
@@ -30,6 +30,8 @@ using System;
 using System.IO;
 using System.Runtime.Serialization.Formatters.Binary;
 using System.Collections;
+using System.Reflection;
+using System.Globalization;
 
 using NUnit.Framework;
 namespace MonoTests.System
@@ -1026,5 +1028,34 @@ namespace MonoTests.System
                                Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0, 1))));
                        }
                }
+
+               [TestFixture]
+               public class GetDaylightChanges
+               {
+                       MethodInfo getChanges;
+
+                       [SetUp]
+                       public void Setup ()
+                       {
+                               var flags = BindingFlags.Instance | BindingFlags.NonPublic;
+                               getChanges = typeof (TimeZoneInfo).GetMethod ("GetDaylightChanges", flags);
+                       }
+
+                       [Test]
+                       public void TestSydneyDaylightChanges ()
+                       {
+                               TimeZoneInfo tz;
+                               if (Environment.OSVersion.Platform == PlatformID.Unix)
+                                       tz = TimeZoneInfo.FindSystemTimeZoneById ("Australia/Sydney");
+                               else
+                                       tz = TimeZoneInfo.FindSystemTimeZoneById ("W. Australia Standard Time");
+
+                               var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {2014});
+
+                               Assert.AreEqual (new TimeSpan (1, 0, 0), changes.Delta);
+                               Assert.AreEqual (new DateTime (2014, 10, 5, 2, 0, 0), changes.Start);
+                               Assert.AreEqual (new DateTime (2014, 4, 6, 3, 0, 0), changes.End);
+                       }
+               }
        }
 }