diff --git a/src/System.Threading.ThreadPool/tests/ThreadPoolTests.cs b/src/System.Threading.ThreadPool/tests/ThreadPoolTests.cs index bc2a0fb1720f..1d56aefca354 100644 --- a/src/System.Threading.ThreadPool/tests/ThreadPoolTests.cs +++ b/src/System.Threading.ThreadPool/tests/ThreadPoolTests.cs @@ -345,19 +345,45 @@ public static void QueueRegisterNegativeTest() WaitOrTimerCallback callback = (state, timedOut) => { }; Assert.Throws(() => ThreadPool.RegisterWaitForSingleObject(null, callback, null, 0, true)); Assert.Throws(() => ThreadPool.RegisterWaitForSingleObject(waitHandle, null, null, 0, true)); - Assert.Throws(() => + AssertExtensions.Throws("millisecondsTimeOutInterval", () => ThreadPool.RegisterWaitForSingleObject(waitHandle, callback, null, -2, true)); - Assert.Throws(() => + AssertExtensions.Throws("millisecondsTimeOutInterval", () => ThreadPool.RegisterWaitForSingleObject(waitHandle, callback, null, (long)-2, true)); - Assert.Throws(() => + if (!PlatformDetection.IsFullFramework) // netfx silently overflows the timeout + { + AssertExtensions.Throws("millisecondsTimeOutInterval", () => + ThreadPool.RegisterWaitForSingleObject(waitHandle, callback, null, (long)int.MaxValue + 1, true)); + } + AssertExtensions.Throws("timeout", () => ThreadPool.RegisterWaitForSingleObject(waitHandle, callback, null, TimeSpan.FromMilliseconds(-2), true)); - Assert.Throws(() => + AssertExtensions.Throws("timeout", () => ThreadPool.RegisterWaitForSingleObject( waitHandle, callback, null, TimeSpan.FromMilliseconds((double)int.MaxValue + 1), true)); + + Assert.Throws(() => ThreadPool.UnsafeRegisterWaitForSingleObject(null, callback, null, 0, true)); + Assert.Throws(() => ThreadPool.UnsafeRegisterWaitForSingleObject(waitHandle, null, null, 0, true)); + AssertExtensions.Throws("millisecondsTimeOutInterval", () => + ThreadPool.UnsafeRegisterWaitForSingleObject(waitHandle, callback, null, -2, true)); + AssertExtensions.Throws("millisecondsTimeOutInterval", () => + ThreadPool.UnsafeRegisterWaitForSingleObject(waitHandle, callback, null, (long)-2, true)); + if (!PlatformDetection.IsFullFramework) // netfx silently overflows the timeout + { + AssertExtensions.Throws("millisecondsTimeOutInterval", () => + ThreadPool.UnsafeRegisterWaitForSingleObject(waitHandle, callback, null, (long)int.MaxValue + 1, true)); + } + AssertExtensions.Throws("timeout", () => + ThreadPool.UnsafeRegisterWaitForSingleObject(waitHandle, callback, null, TimeSpan.FromMilliseconds(-2), true)); + AssertExtensions.Throws("timeout", () => + ThreadPool.UnsafeRegisterWaitForSingleObject( + waitHandle, + callback, + null, + TimeSpan.FromMilliseconds((double)int.MaxValue + 1), + true)); } } }