Esempio n. 1
0
        // Dev11 216491
        // TODO: [Fact(Skip = "SDE Merge - No partial trust yet")]
        public void IsAspNetEnvironment_swallows_security_exception_when_System_Web_is_considered_non_APTCA()
        {
            using (var sandbox = new PartialTrustSandbox(grantReflectionPermission: true))
            {
                var withReflectionPermission = sandbox.CreateInstance <PartialTrustTests>();

                withReflectionPermission.InvokeIsAspNetEnvironment();
            }
        }
        protected override object CreateTestClass()
        {
            sandbox = new PartialTrustSandbox();

            try
            {
                return sandbox.CreateInstance(TestClass, ConstructorArguments);
            }
            catch (SerializationException)
            {
                sandbox.Dispose();
                sandbox = null;

                throw new InvalidOperationException(string.Format("Test class {0} must derive from MarshalByRefObject to use [PartialTrustFact]", TestClass.FullName));
            }
        }
        private void AddOrUpdateConfigSection_result_can_load_in_partial_trust(XDocument config)
        {
            new ConfigFileManipulator().AddOrUpdateConfigSection(
                config, _net45EntityFrameworkVersion);

            config.Element(ConfigFileManipulator.ConfigurationElementName).Add(
                new XElement(
                    ConfigFileManipulator.EntityFrameworkElementName,
                    new XAttribute("codeConfigurationType", typeof(FunctionalTestsConfiguration).AssemblyQualifiedName)));

            var configurationFile = Path.Combine(Environment.CurrentDirectory, "Temp.config");
            config.Save(configurationFile);

            try
            {
                using (var sandbox = new PartialTrustSandbox(configurationFile: configurationFile))
                {
                    sandbox.CreateInstance<ConnectionFactoryConfigTests>()
                           .LoadConfiguration();
                }
            }
            finally
            {
                File.Delete(configurationFile);
            }
        }
        private void AddOrUpdateConfigSection_result_can_load_in_partial_trust(XDocument config)
        {
            new ConfigFileManipulator().AddOrUpdateConfigSection(config, _net45EntityFrameworkVersion);

            var configurationFile = Path.Combine(Environment.CurrentDirectory, "Temp.config");
            config.Save(configurationFile);

            try
            {
                using (var sandbox = new PartialTrustSandbox(configurationFile: configurationFile))
                {
                    sandbox.CreateInstance<ConnectionFactoryConfigTests>()
                        .LoadConfiguration();
                }
            }
            finally
            {
                File.Delete(configurationFile);
            }
        }
        [FullTrust] // Bespoke test with setup that requires full trust
        public void IsAspNetEnvironment_swallows_security_exception_when_System_Web_is_considered_non_APTCA()
        {
            using (var sandbox = new PartialTrustSandbox(grantReflectionPermission: true))
            {
                var withReflectionPermission = sandbox.CreateInstance<PartialTrustTests>();

                withReflectionPermission.InvokeIsAspNetEnvironment();
            }
        }