Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@@ -1 +1 @@
7054084409dab3c72f7be13a1ddc4df6b7c49d9f
048091d2d7cb9dbb624836c4833bfa52d79b89cc

View File

@@ -37,6 +37,7 @@ using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Linq;
using NUnit.Framework;
@@ -373,6 +374,22 @@ namespace MonoTests.System.Collections.Generic {
}
}
[Test]
public void SortTestTrickyPivot ()
{
int[] array = new int[] { 1, 3, 5, 2, 6, 6, 6, 6, 6, 6, 6,7 ,4 };
var list = array.ToList<int>();
list.Sort(delegate (int x, int y)
{
return x < y ? -1 : 1;
});
var res = string.Join (",", list);
Assert.AreEqual ("1,2,3,4,5,6,6,6,6,6,6,6,7", res);
}
[Test]
public void ClearTest ()
{
@@ -1267,9 +1284,9 @@ namespace MonoTests.System.Collections.Generic {
public void Test_Contains_After_Remove ()
{
List<int> list = new List<int> ();
list.Add (2);
list.Add (2);
list.Remove (2);
list.Remove (2);
Assert.AreEqual (false, list.Contains (2), "#0");
}

View File

@@ -2491,6 +2491,7 @@ namespace MonoTests.System.IO
}
[Test]
[Category ("LargeFileSupport")]
public void Position_Large ()
{
// fails if HAVE_LARGE_FILE_SUPPORT is not enabled in device builds
@@ -2513,6 +2514,7 @@ namespace MonoTests.System.IO
}
[Test]
[Category ("LargeFileSupport")]
public void Seek_Large ()
{
// fails if HAVE_LARGE_FILE_SUPPORT is not enabled in device builds
@@ -2537,7 +2539,7 @@ namespace MonoTests.System.IO
}
[Test]
[Category ("AndroidNotWorking")] // locks with offsets bigger than Int32.Max don't work on Android
[Category ("LargeFileSupport")]
public void Lock_Large ()
{
// note: already worked without HAVE_LARGE_FILE_SUPPORT

View File

@@ -100,6 +100,7 @@ public class AssemblyBuilderTest
}
[Test]
[Category ("MobileNotWorking")]
public void DefaultCtor ()
{
Assert.IsNotNull (ab.Evidence, "#1");
@@ -416,7 +417,7 @@ public class AssemblyBuilderTest
}
[Test]
[Category ("AndroidNotWorking")] // DefineResource doesn't allow path in its fileName parameter and the test attempts to write to / in effect
[Category ("MobileNotWorking")] // DefineResource doesn't allow path in its fileName parameter and the test attempts to write to / in effect
public void TestDefineResource ()
{
ab.DefineResource ("foo", "FOO", "foo.txt", ResourceAttributes.Public);
@@ -593,12 +594,16 @@ public class AssemblyBuilderTest
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.Compilerservices.SymbolWriter assembly
public void TestDefineDynamicModule ()
{
ab.DefineDynamicModule ("foo", "foo.dll");
ab.DefineDynamicModule ("foo2", true);
ab.DefineDynamicModule ("foo3", "foo3.dll");
}
[Category ("MobileNotWorking")] //XA doesn't ship SymbolWriter. https://bugzilla.xamarin.com/show_bug.cgi?id=53038
public void TestDefineDynamicModuleWithSymbolWriter ()
{
ab.DefineDynamicModule ("foo2", true);
ab.DefineDynamicModule ("foo4", "foo4.dll", true);
}

View File

@@ -136,11 +136,10 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_Name_Null ()
{
AssemblyBuilder ab = genAssembly ();
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
try {
mb.DefineType ((string) null);
Assert.Fail ("#1");
@@ -153,11 +152,10 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_Name_Empty ()
{
AssemblyBuilder ab = genAssembly ();
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
try {
mb.DefineType (string.Empty);
Assert.Fail ("#1");
@@ -171,11 +169,10 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_Name_NullChar ()
{
AssemblyBuilder ab = genAssembly ();
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
try {
mb.DefineType ("\0test");
Assert.Fail ("#1");
@@ -191,11 +188,10 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_InterfaceNotAbstract ()
{
AssemblyBuilder ab = genAssembly ();
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
try {
mb.DefineType ("ITest1", TypeAttributes.Interface);
@@ -228,13 +224,12 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_Parent_Interface ()
{
TypeBuilder tb;
AssemblyBuilder ab = genAssembly ();
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
tb = mb.DefineType ("Foo", TypeAttributes.Class,
typeof (ICollection));
@@ -246,11 +241,10 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_TypeSize ()
{
AssemblyBuilder ab = genAssembly ();
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
TypeBuilder tb = mb.DefineType ("Foo", TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.SequentialLayout,
typeof (ValueType), 1);
@@ -258,11 +252,10 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
[ExpectedException (typeof (ArgumentException))]
public void DuplicateTypeName () {
AssemblyBuilder ab = genAssembly ();
ModuleBuilder module = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
ModuleBuilder module = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
var itb = module.DefineType ("TBase", TypeAttributes.Public);
@@ -274,7 +267,7 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
[Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
[Category ("MobileNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DuplicateSymbolDocument ()
{
AssemblyBuilder ab = genAssembly ();

View File

@@ -1 +1 @@
c145c6770452545322a5dd359447663fa340d536
94cfff6e2fd7bca624f849d260fb8df58d94487d

View File

@@ -215,7 +215,6 @@ namespace MonoTests.System.Reflection
#if !MONOTOUCH && !FULL_AOT_RUNTIME // Reflection.Emit is not supported.
[Test]
[Category("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter
public void GetModules_MissingFile ()
{
AssemblyName newName = new AssemblyName ();
@@ -223,7 +222,7 @@ namespace MonoTests.System.Reflection
AssemblyBuilder ab = Thread.GetDomain().DefineDynamicAssembly (newName, AssemblyBuilderAccess.RunAndSave, TempFolder);
ModuleBuilder mb = ab.DefineDynamicModule ("myDynamicModule1", "myDynamicModule.dll", true);
ModuleBuilder mb = ab.DefineDynamicModule ("myDynamicModule1", "myDynamicModule.dll", false);
ab.Save ("test_assembly.dll");
@@ -474,11 +473,7 @@ namespace MonoTests.System.Reflection
// with the semantics of aot'ed assembly loading, as
// aot may assert when loading. This assumes that it's
// safe to greedly load everything.
#if FULL_AOT_DESKTOP
string [] names = { "testing_aot_full_corlib_test", "winaot_corlib_test" };
#else
string [] names = { "corlib_test_net_1_1", "corlib_test_net_2_0", "corlib_test_net_4_0", "corlib_test_net_4_5", "net_4_x_corlib_test", "corlib_plattest", "mscorlibtests", "BclTests" };
#endif
var names = new string[] { Assembly.GetCallingAssembly ().GetName ().Name };
foreach (string s in names)
if (Assembly.LoadWithPartialName (s) != null)
@@ -730,12 +725,12 @@ namespace MonoTests.System.Reflection
}
[Test]
[Category ("AndroidNotWorking")] // Assemblies in Xamarin.Android cannot be directly as files
[Category ("AndroidNotWorking")] // Xamarin.Android assemblies are bundled so they don't exist in the file system.
public void ReflectionOnlyLoadFrom ()
{
string loc = typeof (AssemblyTest).Assembly.Location;
string filename = Path.GetFileName (loc);
Assembly assembly = Assembly.ReflectionOnlyLoadFrom (filename);
Assembly assembly = Assembly.ReflectionOnlyLoadFrom (loc);
Assert.IsNotNull (assembly);
Assert.IsTrue (assembly.ReflectionOnly);

View File

@@ -343,7 +343,6 @@ public class ModuleTest
}
#if !MONOTOUCH && !FULL_AOT_RUNTIME
[Test]
[Category ("AndroidNotWorking")] // Mono.CompilerServices.SymbolWriter not available for Xamarin.Android
public void GetTypes ()
{
AssemblyName newName = new AssemblyName ();
@@ -351,7 +350,7 @@ public class ModuleTest
AssemblyBuilder ab = Thread.GetDomain().DefineDynamicAssembly (newName, AssemblyBuilderAccess.RunAndSave, TempFolder);
ModuleBuilder mb = ab.DefineDynamicModule ("myDynamicModule1", "myDynamicModule" + ".dll", true);
ModuleBuilder mb = ab.DefineDynamicModule ("myDynamicModule1", "myDynamicModule" + ".dll", false);
TypeBuilder tb = mb.DefineType ("Foo", TypeAttributes.Public);
tb.CreateType ();

View File

@@ -785,6 +785,7 @@ namespace MonoTests.System.Resources
}
[Test]
[Category ("SatelliteAssembliesNotWorking")]
public void TestSatellites ()
{
ResourceManager manager = new ResourceManager("Resources", GetType ().Assembly);

View File

@@ -74,11 +74,7 @@ namespace MonoTests.System.Runtime.InteropServices {
{
string dirname = RuntimeEnvironment.GetRuntimeDirectory ();
Assert.IsNotNull (dirname, "GetRuntimeDirectory");
#if MONODROID
Assert.IsTrue (dirname.Length == 0, "directory name empty");
#else
Assert.IsTrue (Directory.Exists (dirname), "Exists");
#endif
Assert.IsTrue (dirname.Length == 0 || Directory.Exists (dirname), "Exists");
}
[Test]

View File

@@ -48,10 +48,7 @@ namespace MonoTests.System.Runtime.InteropServices
protected override void Dispose (bool manual)
{
disposed = true;
#if !MONODROID
// Bombs on Android (ObjectDisposedException)
base.Dispose (manual);
#endif
}
}
@@ -80,7 +77,6 @@ namespace MonoTests.System.Runtime.InteropServices
[Test]
[ExpectedException (typeof (ObjectDisposedException))]
[Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void BadDispose2 ()
{
FakeSafeHandle sf = new FakeSafeHandle ();
@@ -91,7 +87,6 @@ namespace MonoTests.System.Runtime.InteropServices
[Test]
[ExpectedException (typeof (ObjectDisposedException))]
[Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void BadDispose3 ()
{
FakeSafeHandle sf = new FakeSafeHandle ();
@@ -120,7 +115,6 @@ namespace MonoTests.System.Runtime.InteropServices
}
[Test]
[Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void GoodDispose ()
{
int dummyHandle = 0xDEAD;
@@ -238,7 +232,6 @@ namespace MonoTests.System.Runtime.InteropServices
}
[Test]
[Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void ReleaseAfterDispose1 ()
{
int dummyHandle = 0xDEAD;
@@ -267,7 +260,6 @@ namespace MonoTests.System.Runtime.InteropServices
[Test]
[ExpectedException (typeof (ObjectDisposedException))]
[Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void ReleaseAfterDispose2 ()
{
FakeSafeHandle sf = new FakeSafeHandle (true);
@@ -286,7 +278,6 @@ namespace MonoTests.System.Runtime.InteropServices
}
[Test]
[Category ("AndroidNotWorking")] // Not until Dispose runtime crasher in FakeSafeHandle is fixed
public void NoReleaseUnowned ()
{
FakeSafeHandle sf = new FakeSafeHandle (false);

View File

@@ -412,6 +412,7 @@ namespace MonoTests.System {
}
[Test]
[Category ("MobileNotWorking")]
[ExpectedException (typeof (ArgumentNullException))]
public void GetObject_UrlNull ()
{

View File

@@ -311,88 +311,47 @@ namespace MonoTests.System {
}
[Test]
public void Check_InvalidOperationException() {
public void Check_NoInvalidOperationException ()
{
Array arr = new object[] {new SomeComparable (), new SomeIncomparable (), new SomeComparable ()};
Array.Sort (arr);
Array.Sort (arr, (Array)null);
Array.Sort (arr, (IComparer)null);
Array.Sort (arr, 0, 3);
Array.Sort (arr, null, null);
Array.Sort (arr, null, 0, 3);
Array.Sort (arr, 0, 3, null);
Array.Sort (arr, null, 0, 3, null);
}
[Test]
public void Check_NoInvalidOperationException_Generic ()
{
object[] arr = new object[] {new SomeComparable (), new SomeIncomparable (), new SomeComparable ()};
try {
Array.Sort (arr);
Assert.Fail ("#1");
} catch (InvalidOperationException) {}
Array.Sort<object> (arr);
try {
Array.Sort (arr, (Array)null);
Assert.Fail ("#2");
} catch (InvalidOperationException) {}
Array.Sort<object, object> (arr, null);
try {
Array.Sort (arr, (IComparer)null);
Assert.Fail ("#3");
} catch (InvalidOperationException) {}
Array.Sort<object> (arr, (IComparer<object>)null);
try {
Array.Sort (arr, 0, 3);
Assert.Fail ("#4");
} catch (InvalidOperationException) {}
Array.Sort<object, object> (arr, null, null);
try {
Array.Sort (arr, null, null);
Assert.Fail ("#5");
} catch (InvalidOperationException) {}
Array.Sort<object> (arr, 0, 3);
try {
Array.Sort (arr, null, 0, 3);
Assert.Fail ("#6");
} catch (InvalidOperationException) {}
Array.Sort<object, object> (arr, null, 0, 3);
try {
Array.Sort (arr, 0, 3, null);
Assert.Fail ("#7");
} catch (InvalidOperationException) {}
Array.Sort<object> (arr, 0, 3, null);
try {
Array.Sort (arr, null, 0, 3, null);
Assert.Fail ("#8");
} catch (InvalidOperationException) {}
try {
Array.Sort<object> (arr);
Assert.Fail ("#9");
} catch (InvalidOperationException) {}
try {
Array.Sort<object, object> (arr, null);
Assert.Fail ("#10");
} catch (InvalidOperationException) {}
try {
Array.Sort<object> (arr, (IComparer<object>)null);
Assert.Fail ("#11");
} catch (InvalidOperationException) {}
try {
Array.Sort<object, object> (arr, null, null);
Assert.Fail ("#12");
} catch (InvalidOperationException) {}
try {
Array.Sort<object> (arr, 0, 3);
Assert.Fail ("#13");
} catch (InvalidOperationException) {}
try {
Array.Sort<object, object> (arr, null, 0, 3);
Assert.Fail ("#14");
} catch (InvalidOperationException) {}
try {
Array.Sort<object> (arr, 0, 3, null);
Assert.Fail ("#15");
} catch (InvalidOperationException) {}
try {
Array.Sort<object, object> (arr, null, 0, 3, null);
Assert.Fail ("#16");
} catch (InvalidOperationException) {}
Array.Sort<object, object> (arr, null, 0, 3, null);
}
}
}

View File

@@ -779,6 +779,14 @@ public class ArrayTest
Array.CreateInstance (typeof (Int32), (long[])null);
}
[Test]
public void CreateInstanceVoid ()
{
Assert.Throws<NotSupportedException> (delegate () {
Array.CreateInstance (typeof (void), 1);
});
}
[Test]
public void TestGetEnumerator() {
String[] s1 = {"this", "is", "a", "test"};
@@ -995,7 +1003,6 @@ public class ArrayTest
int[] myBoundArray = new int[1] { Int32.MinValue };
Array myExtremeArray=Array.CreateInstance ( typeof(String), myLengthArray, myBoundArray );
Assert.AreEqual (Int32.MaxValue, ((IList)myExtremeArray).IndexOf (42), "AD04");
}
[Test]
@@ -2575,6 +2582,26 @@ public class ArrayTest
}
}
[Test]
public void TestSortComparableMixed()
{
var m = new TestSortComparableMixed_Comparer ();
var arr = new object [] { 1, 2, m, 4, 5, 6, 7, 8, 9, 10 };
Array.Sort (arr);
var expected = new object [] { m, 1, 2, 4, 5, 6, 7, 8, 9, 10 };
Assert.AreEqual (expected, arr);
}
class TestSortComparableMixed_Comparer : IComparable
{
public int CompareTo (object other)
{
return -1;
}
}
[Test]
public void TestInitializeEmpty()
{

View File

@@ -467,10 +467,14 @@ public class Int32Test
int hundred = 100;
int neghund = -100;
Assert.IsTrue ( hundred.ToString ("#;#") == "100", "#TS1");
Assert.IsTrue ( hundred.ToString ("-#;#") == "-100", "#TS2");
Assert.IsTrue ( neghund.ToString ("#;#") == "100", "#TS3");
Assert.IsTrue ( neghund.ToString ("#;-#") == "-100", "#TS3");
Assert.AreEqual ("100", hundred.ToString ("#;#"), "#TS1");
Assert.AreEqual ("-100", hundred.ToString ("-#;#"), "#TS2");
Assert.AreEqual ("100", neghund.ToString ("#;#"), "#TS3");
Assert.AreEqual ("-100", neghund.ToString ("#;-#"), "#TS4");
Assert.AreEqual ("3", 0.ToString ("3;;"), "#TS5");
Assert.AreEqual ("3", 0.ToString ("3;2;"), "#TS6");
Assert.AreEqual ("3", 0.ToString ("3;"), "#TS7");
Assert.AreEqual ("3", 0.ToString ("3;;;;;;;"), "#TS8");
}
[Test]

View File

@@ -300,7 +300,7 @@ namespace MonoTests.System
}
[Test]
public void DSTTransisions ()
public void DSTTransitions ()
{
DateTime beforeDST = new DateTime (2007, 03, 25, 0, 59, 59, DateTimeKind.Unspecified);
DateTime startDST = new DateTime (2007, 03, 25, 2, 0, 0, DateTimeKind.Unspecified);
@@ -308,12 +308,12 @@ namespace MonoTests.System
DateTime afterDST = new DateTime (2007, 10, 28, 2, 0, 0, DateTimeKind.Unspecified);
Assert.IsFalse (london.IsDaylightSavingTime (beforeDST), "Just before DST");
Assert.IsTrue (london.IsDaylightSavingTime (startDST), "the first seconds of DST");
Assert.IsFalse (london.IsDaylightSavingTime (endDST), "The last seconds of DST");
Assert.IsTrue (london.IsDaylightSavingTime (endDST), "The last seconds of DST");
Assert.IsFalse (london.IsDaylightSavingTime (afterDST), "Just after DST");
}
[Test]
public void DSTTransisionsUTC ()
public void DSTTransitionsUTC ()
{
DateTime beforeDST = new DateTime (2007, 03, 25, 0, 59, 59, DateTimeKind.Utc);
DateTime startDST = new DateTime (2007, 03, 25, 1, 0, 0, DateTimeKind.Utc);
@@ -867,9 +867,12 @@ namespace MonoTests.System
[Test]
public void WindowsRegistryTimezoneWithParentheses ()
{
var method = (MethodInfo) typeof (TimeZoneInfo).GetMember ("TrimSpecial", MemberTypes.Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)[0];
var memberInfos = typeof (TimeZoneInfo).GetMember ("TrimSpecial", MemberTypes.Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
var name = method.Invoke (null, new object [] { " <---> Central Standard Time (Mexico) ||<<>>" });
if (memberInfos.Length == 0)
Assert.Ignore ("TrimSpecial method not found");
var name = ((MethodInfo)memberInfos[0]).Invoke (null, new object [] { " <---> Central Standard Time (Mexico) ||<<>>" });
Assert.AreEqual (name, "Central Standard Time (Mexico)", "#1");
}
#endif
@@ -1179,8 +1182,8 @@ namespace MonoTests.System
d = dst1End.Add (-dstOffset);
Assert.AreEqual(dstUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0,-1))));
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d));
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0, 1))));
Assert.AreEqual(dstUtcOffset, cairo.GetUtcOffset (d));
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,1,0, 1))));
d = dst2Start.Add (dstOffset);
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0,-1))));
@@ -1189,8 +1192,8 @@ namespace MonoTests.System
d = dst2End.Add (-dstOffset);
Assert.AreEqual(dstUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0,-1))));
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d));
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0, 1))));
Assert.AreEqual(dstUtcOffset, cairo.GetUtcOffset (d));
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,1,0, 1))));
}
[Test]

View File

@@ -14,6 +14,7 @@ using System;
using System.IO;
using System.Threading;
using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
namespace MonoTests.System {
@@ -270,6 +271,47 @@ public class TimeZoneTest {
Assert.IsTrue (tz.ToLocalTime (dst_start_utc.Add (new TimeSpan (1, 0, 0))) < tz.ToLocalTime (dst_start_utc.Add (new TimeSpan (1, 1, 0))), "0:4:00 < 0:4:01");
}
[Test]
public void GetUTCNowAtDSTBoundaries ()
{
TimeZoneInfo.TransitionTime startTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 2, 0, 0), 3, 5, DayOfWeek.Sunday);
TimeZoneInfo.TransitionTime endTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 3, 0, 0), 10, 5, DayOfWeek.Sunday);
TimeSpan delta = TimeSpan.FromMinutes(60.0);
TimeZoneInfo.AdjustmentRule adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1970, 1, 1), DateTime.MaxValue.Date, delta, startTransition, endTransition);
TimeZoneInfo.TransitionTime startTrans = adjustment.DaylightTransitionStart;
TimeZoneInfo.TransitionTime endTrans = adjustment.DaylightTransitionEnd;
TimeZoneInfo.AdjustmentRule[] adjustments = { adjustment };
TimeZoneInfo tzInfo = TimeZoneInfo.CreateCustomTimeZone("MY Standard Time", TimeSpan.Zero, "MST", "MST", "MDT", adjustments);
// There is no .NET API to set timezone. Use reflection to assign time zone to the TimeZoneInfo.local field.
FieldInfo localTimeZone = typeof(TimeZoneInfo).GetField("local", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
localTimeZone.SetValue(null, tzInfo);
DateTime st = new DateTime(2016, 3, 27, 1, 0, 0, DateTimeKind.Local);
Assert.IsTrue (!tzInfo.IsDaylightSavingTime(st));
Assert.IsTrue (!tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 1));
st = new DateTime(2016, 3, 27, 3, 0, 0, DateTimeKind.Local);
Assert.IsTrue (tzInfo.IsDaylightSavingTime(st));
Assert.IsTrue (!tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 2));
st = new DateTime(2016, 10, 30, 2, 0, 0, DateTimeKind.Local);
Assert.IsTrue (tzInfo.IsDaylightSavingTime(st));
Assert.IsTrue (!tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 1));
st = new DateTime(2016, 10, 30, 3, 0, 0, DateTimeKind.Local);
Assert.IsTrue (!tzInfo.IsDaylightSavingTime(st));
Assert.IsTrue (tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 3));
st = new DateTime(2016, 10, 30, 4, 0, 0, DateTimeKind.Local);
Assert.IsTrue (!tzInfo.IsDaylightSavingTime(st));
Assert.IsTrue (!tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 4));
}
[Test]
public void GetUtcOffsetAtDSTBoundary ()
{
@@ -302,11 +344,12 @@ public class TimeZoneTest {
Assert.Ignore (tz.StandardName + " did not observe daylight saving time during " + year + ".");
var standardOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(-1));
var dstOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(61));
Assert.AreEqual(standardOffset, tz.GetUtcOffset (dst_end));
Assert.AreEqual(standardOffset, tz.GetUtcOffset (dst_end.Add (daylightChanges.Delta.Negate ().Add (TimeSpan.FromSeconds(1)))));
Assert.AreEqual(standardOffset, tz.GetUtcOffset (dst_end.Add(daylightChanges.Delta.Negate ())));
Assert.AreNotEqual(standardOffset, tz.GetUtcOffset (dst_end.Add(daylightChanges.Delta.Negate ().Add (TimeSpan.FromSeconds(-1)))));
Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add (daylightChanges.Delta.Negate ().Add (TimeSpan.FromSeconds(1)))));
Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add(daylightChanges.Delta.Negate ())));
Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add(daylightChanges.Delta.Negate ().Add (TimeSpan.FromSeconds(-1)))));
}

View File

@@ -1 +1 @@
100f1c362742134360fd3562f632b1192f0d50c3
9cc8ca79a413f707d27ad210899583c3fdb03456