From 8590bdf2146b86c179fd4cbe78f721d4f0b581c7 Mon Sep 17 00:00:00 2001 From: Aditya Mandaleeka Date: Tue, 3 May 2016 12:33:28 -0700 Subject: Add test for Begin/EndInvoke throwing PlatformNotSupportedException. --- .../threading/delegate/BeginInvokeEndInvoke.cs | 58 ++++++++++++++++++++++ .../threading/delegate/BeginInvokeEndInvoke.csproj | 43 ++++++++++++++++ .../baseservices/threading/delegate/project.json | 44 ++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 tests/src/baseservices/threading/delegate/BeginInvokeEndInvoke.cs create mode 100644 tests/src/baseservices/threading/delegate/BeginInvokeEndInvoke.csproj create mode 100644 tests/src/baseservices/threading/delegate/project.json (limited to 'tests') diff --git a/tests/src/baseservices/threading/delegate/BeginInvokeEndInvoke.cs b/tests/src/baseservices/threading/delegate/BeginInvokeEndInvoke.cs new file mode 100644 index 0000000000..c806f516c4 --- /dev/null +++ b/tests/src/baseservices/threading/delegate/BeginInvokeEndInvoke.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; + +namespace DelegateTest +{ + class DelegateCommon + { + public static string TestMethod(int input) + { + return input.ToString(); + } + } + + class BeginInvokeEndInvokeTest + { + public delegate string AsyncMethodCaller(int input); + static int Main(string[] args) + { + IAsyncResult result = null; + AsyncMethodCaller caller = new AsyncMethodCaller(DelegateCommon.TestMethod); + + try + { + result = caller.BeginInvoke(123, null, null); + } + catch (PlatformNotSupportedException) + { + // Expected + } + catch (Exception ex) + { + Console.WriteLine("BeginInvoke resulted in unexpected exception: {0}", ex.ToString()); + Console.WriteLine("FAILED!"); + return -1; + } + + try + { + caller.EndInvoke(result); + } + catch (PlatformNotSupportedException) + { + // Expected + } + catch (Exception ex) + { + Console.WriteLine("EndInvoke resulted in unexpected exception: {0}", ex.ToString()); + Console.WriteLine("FAILED!"); + return -1; + } + + return 100; + } + } +} diff --git a/tests/src/baseservices/threading/delegate/BeginInvokeEndInvoke.csproj b/tests/src/baseservices/threading/delegate/BeginInvokeEndInvoke.csproj new file mode 100644 index 0000000000..0de88ad1af --- /dev/null +++ b/tests/src/baseservices/threading/delegate/BeginInvokeEndInvoke.csproj @@ -0,0 +1,43 @@ + + + + + Debug + AnyCPU + 2.0 + {c485e164-f82c-4a4f-a02e-bc711827e5be} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages + ..\..\ + 7a9bfb7d + true + false + BuildAndRun + 1 + + + + + + + + + False + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/baseservices/threading/delegate/project.json b/tests/src/baseservices/threading/delegate/project.json new file mode 100644 index 0000000000..6d59b926ae --- /dev/null +++ b/tests/src/baseservices/threading/delegate/project.json @@ -0,0 +1,44 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10-rc2-23816", + "System.Collections.NonGeneric": "4.0.1-rc2-23816", + "System.Collections.Specialized": "4.0.1-rc2-23816", + "System.ComponentModel": "4.0.1-rc2-23816", + "System.Console": "4.0.0-rc2-23816", + "System.Diagnostics.Process": "4.0.0-rc2-23816", + "System.Globalization": "4.0.10-rc2-23816", + "System.Globalization.Calendars": "4.0.0-rc2-23816", + "System.IO": "4.0.10-rc2-23816", + "System.IO.FileSystem": "4.0.0-rc2-23816", + "System.IO.FileSystem.Primitives": "4.0.0-rc2-23816", + "System.Linq": "4.0.1-rc2-23816", + "System.Linq.Queryable": "4.0.1-rc2-23816", + "System.Reflection": "4.0.10-rc2-23816", + "System.Reflection.Primitives": "4.0.0-rc2-23816", + "System.Runtime": "4.0.20-rc2-23816", + "System.Runtime.Extensions": "4.0.10-rc2-23816", + "System.Runtime.Handles": "4.0.0-rc2-23816", + "System.Runtime.InteropServices": "4.0.20-rc2-23816", + "System.Runtime.Loader": "4.0.0-rc2-23816", + "System.Text.Encoding": "4.0.10-rc2-23816", + "System.Threading": "4.0.10-rc2-23816", + "System.Threading.AccessControl": "4.0.0-rc2-23816", + "System.Xml.ReaderWriter": "4.0.11-rc2-23816", + "System.Xml.XDocument": "4.0.11-rc2-23816", + "System.Xml.XmlDocument": "4.0.1-rc2-23816", + "System.Xml.XmlSerializer": "4.0.11-rc2-23816" + }, + "frameworks": { + "dnxcore50": {} + }, + "runtimes": { + "win7-x86": {}, + "win7-x64": {}, + "ubuntu.14.04-x64": {}, + "osx.10.10-x64": {}, + "centos.7-x64": {}, + "rhel.7-x64": {}, + "debian.8.2-x64": {} + } +} -- cgit v1.2.3