Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/NUnitLite.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Urban <bernhard.urban@xamarin.com>2018-02-26 18:47:11 +0300
committerGitHub <noreply@github.com>2018-02-26 18:47:11 +0300
commit70bb70b0ffd0109aadaa6e4ea178972d4fb63ea3 (patch)
treee3677c983574bb79e3e75b6ceb2af648f0dfddc9
parent09ad9cf1ea5278e12ca8764565bab2e71640409c (diff)
[FinallyDelegate] rely on PlatformNotSupportedException in order to determine remoting support (#10)
-rw-r--r--NUnitLite-1.0.0/src/framework/FinallyDelegate.cs30
1 files changed, 10 insertions, 20 deletions
diff --git a/NUnitLite-1.0.0/src/framework/FinallyDelegate.cs b/NUnitLite-1.0.0/src/framework/FinallyDelegate.cs
index dfa94b6..d94cf79 100644
--- a/NUnitLite-1.0.0/src/framework/FinallyDelegate.cs
+++ b/NUnitLite-1.0.0/src/framework/FinallyDelegate.cs
@@ -24,10 +24,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
-#if __IOS__ || __WATCHOS__ || __TVOS__
-#define NO_REMOTING
-#endif
-
using System;
using System.Diagnostics;
using System.Threading;
@@ -76,14 +72,12 @@ namespace NUnit.Framework.Internal
// Thread_1 creates Thread_2, it needs to have the same "thread local" values.
// that is achieved with `CallContext`.
//
- // Unfortunately, remoting isn't available on every platform, thus we can't
- // support this scenario. Luckily, this scenario is very rare.
+ // Unfortunately, remoting isn't available on every platform (it will
+ // throw PlatformNotSupportedexception), thus we can't support this
+ // scenario. Luckily, this scenario is very rare.
-#if NO_REMOTING
- static Container container;
-#else
+ Container container = null;
private static readonly string CONTEXT_KEY = "TestResultName";
-#endif
public FinallyDelegate () {
this.testStack = new Stack<Tuple<TestExecutionContext, long, TestResult>>();
@@ -96,22 +90,18 @@ namespace NUnit.Framework.Internal
/* keep name in LogicalCallContext, because this will be inherited by
* Threads spawned by the test case */
var guid = Guid.NewGuid();
-#if NO_REMOTING
- container = new Container (guid);
-#else
- CallContext.SetData(CONTEXT_KEY, new Container(guid));
-#endif
+ try {
+ CallContext.SetData(CONTEXT_KEY, new Container(guid));
+ } catch {
+ container = new Container (guid);
+ }
this.lookupTable.Add(guid, result);
this.testStack.Push(frame);
}
public void HandleUnhandledExc (Exception ex) {
-#if NO_REMOTING
- Container c = container;
-#else
- Container c = (Container) CallContext.GetData(CONTEXT_KEY);
-#endif
+ Container c = container ?? (Container) CallContext.GetData(CONTEXT_KEY);
TestResult result = this.lookupTable [c.guid];
result.RecordException(ex);
result.ThreadCrashFail = true;