Exemplo n.º 1
0
        protected override void Arrange()
        {
            base.Arrange();

            var fullyTrustedAssemblies = this.GetFullyTrustedAssemblies().ToArray();
            var unsignedAssemblies = fullyTrustedAssemblies.Where(sn => sn.PublicKey.ToString() == "");
            if (unsignedAssemblies.Any())
            {
                Assert.Inconclusive("Full trust assemblies must be signed. This test will be ignored. Unsigned assemblies: " + unsignedAssemblies.Aggregate("", (a, sn) => a + sn.Name + " "));
            }

            var evidence = new Evidence();
            evidence.AddHostEvidence(new Zone(SecurityZone.Intranet));
            var set = SecurityManager.GetStandardSandbox(evidence);
            this.AddPermissions(set);
            this.appDomain =
                AppDomain.CreateDomain(
                    "partial trust",
                    null,
                    AppDomain.CurrentDomain.SetupInformation,
                    set,
                    fullyTrustedAssemblies);

            this.loggerProxy = ((LoggerProxy)this.appDomain.CreateInstanceAndUnwrap(typeof(LoggerProxy).Assembly.FullName, typeof(LoggerProxy).FullName));
            this.loggerProxy.Setup();
        }