Here are the examples of the csharp api class NUnit.Framework.Assertions.AdhocTestExecutionTests.RestoreExecutionContext(TestExecutionContext) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: nunit
Source File: AdhocTestExecutionTests.cs
View license
[TestCaseSource(typeof(AdhocTests), nameof(AdhocTests.TestMethods))]
        public void CanCallAssertWithoutTestExecutionContext(MethodInfo method)
            var savedContext = ClearExecutionContext();
            Exception testException = null;

                // Currently, we know all the tests are static, without arguments
                method.Invoke(null, null);
            catch(Exception ex)
                testException = ex is TargetInvocationException
                    ? ex.InnerException
                    : ex;

            // Throw any exception we got only after context is restored
            if (testException != null)
                throw testException;