Exemplo n.º 1
0
        private static bool ShouldTestOnlyInFullTrust()
        {
            var currentTest = PartialTrustHelper <T> .FindCurrentTestMethodInfo();

            // If we can't find a compatible test, it might be because we cannot run it remotely in the
            // AppDomain e.g. if it's a parameterised test, in which case fail with a note
            if (currentTest == null)
            {
                Assert.Fail("Cannot find current test; is test parameterised?");
            }

            return(currentTest.GetCustomAttributes(typeof(TestOnlyInFullTrustAttribute), false).Any());
        }
Exemplo n.º 2
0
        protected void PartialTrustSetup()
        {
            if (ShouldTestOnlyInFullTrust())
            {
                // Do not run this test in partial trust
                TestSetup();
                return;
            }

            // First, run the TestSetup method in the partial trust domain
            _methodRunner.Run(ExpressionHelper.GetMethodInfo <AbstractPartialTrustFixture <T> >(x => x.TestSetup()));

            // Now, run the actual test in the same appdomain
            PartialTrustHelper <T> .CheckRunNUnitTestInPartialTrust(_partialTrustAppDomain, _methodRunner);

            // If we get here, we've had no exceptions, so throw an NUnit SuccessException which will avoid rerunning the test
            // in the existing full-trust appdomain and cause the test to pass
            throw new SuccessException("Automatically avoided running test in full trust as it passed in partial trust");
        }
Exemplo n.º 3
0
        protected virtual void FixtureSetup()
        {
            _partialTrustAppDomain = PartialTrustHelper <T> .CreatePartialTrustDomain();

            _methodRunner = PartialTrustHelper <T> .GenerateMarshaller(_partialTrustAppDomain);
        }