public void CopyTo_copies_all_parameters_to_new_AppDomainSetup()
        {
            AppDomainParameters parms = CreateParameters();
            AppDomainParameters newInstance = new AppDomainParameters();

            parms.CopyTo(newInstance);
            AssertAllPropertiesAreEqual(parms, newInstance);

            AppDomainSetup setup = new AppDomainSetup();
            parms.CopyTo(setup);

            //AppDomainSetup does its own thing with the values that are copied and we don't control
            //that (or even want to try to control it; not our responsiblity), which is why the
            //result of copying to System.AppDomainSetup is not verified. The first assertion ensures
            //that the correct values are set.
        }
Exemplo n.º 2
0
        public void CustomAppDomainSetupIsUsed()
        {
            string baseDir = typeof(VerifyAppDomainRunner).Assembly.CodeBase.Substring(8);
            baseDir = Path.GetDirectoryName(Path.GetFullPath(baseDir));
            AppDomainParameters parms = new AppDomainParameters();
            parms.ApplicationBase = "..";
            parms.ApplicationName = "CustomAppDomainSetupIsUsed-test-domain";
            parms.CachePath = Path.Combine(baseDir, "cache-tmp");
            parms.ConfigurationFile = Path.Combine(baseDir, "fitSharpTest.dll.alt.config");
            parms.DynamicBase = Path.Combine(baseDir, "dynamic-tmp");
            parms.PrivateBinPath = ".";
            parms.ShouldExcludeApplicationBaseFromAssemblyProbe = false;
            using (XmlWriter writer = XmlWriter.Create("domainSetup.xml")) {
                parms.Write(writer);
                writer.Flush();
                writer.Close();
            }

            int result = new Shell().Run(new[] {"-d", "domainSetup.xml",
                "-r", typeof (VerifyAppDomainRunner).FullName + "," + typeof (VerifyAppDomainRunner).Assembly.CodeBase});
            Assert.That(result, Is.EqualTo(0));
        }
 //[Test]
 //public void foo() {
 //    using (XmlWriter writer = XmlWriter.Create(@"C:\oss\fitsharp\source\fitSharpTest\domainSetup.xml")) {
 //        CreateParameters().Write(writer);
 //        writer.Flush();
 //        writer.Close();
 //    }
 //}
 private void AssertAllPropertiesAreEqual(AppDomainParameters expected, AppDomainParameters actual)
 {
     Assert.That(actual.ApplicationBase, Is.EqualTo(expected.ApplicationBase));
     Assert.That(actual.ApplicationName, Is.EqualTo(expected.ApplicationName));
     Assert.That(actual.CachePath, Is.EqualTo(expected.CachePath));
     Assert.That(actual.ConfigurationFile, Is.EqualTo(expected.ConfigurationFile));
     Assert.That(actual.DynamicBase, Is.EqualTo(expected.DynamicBase));
     Assert.That(actual.LicenseFile, Is.EqualTo(expected.LicenseFile));
     Assert.That(actual.PrivateBinPath, Is.EqualTo(expected.PrivateBinPath));
     Assert.That(actual.ShouldExcludeApplicationBaseFromAssemblyProbe, Is.EqualTo(expected.ShouldExcludeApplicationBaseFromAssemblyProbe));
     Assert.That(actual.ShadowCopyDirectories, Is.EqualTo(expected.ShadowCopyDirectories));
     Assert.That(actual.ShadowCopyFiles, Is.EqualTo(expected.ShadowCopyFiles));
 }
 public void setter_throws_when_PrivateBinPath_contains_dirs_not_under_ApplicationBase()
 {
     AppDomainParameters parms = new AppDomainParameters();
     parms.ApplicationBase = @"C:\foo";
     Error.Expect<InvalidOperationException>(() => parms.PrivateBinPath = @"bin;C:\bar\bin");
 }
Exemplo n.º 5
0
        public static AppDomainParameters Read(XmlReader reader)
        {
            AppDomainParameters rv = new AppDomainParameters();
            XmlDocument xd = new XmlDocument();
            xd.Load(reader);

            foreach (XmlNode node in xd.DocumentElement.ChildNodes) {
                XmlElement el = node as XmlElement;
                if (el != null) {
                    switch (el.LocalName) {
                        case "ApplicationBase":
                            rv.ApplicationBase = SafeTrim(el.InnerText);
                            break;
                        case "ApplicationName":
                            rv.ApplicationName = SafeTrim(el.InnerText);
                            break;
                        case "CachePath":
                            rv.CachePath = SafeTrim(el.InnerText);
                            break;
                        case "ConfigurationFile":
                            rv.ConfigurationFile = SafeTrim(el.InnerText);
                            break;
                        case "DynamicBase":
                            rv.DynamicBase = SafeTrim(el.InnerText);
                            break;
                        case "LicenseFile":
                            rv.LicenseFile = SafeTrim(el.InnerText);
                            break;
                        case "PrivateBinPath":
                            rv.PrivateBinPath = SafeTrim(el.InnerText);
                            break;
                        case "PrivateBinPathProbe":
                            ((IAppDomainSetup)rv).PrivateBinPathProbe = SafeTrim(el.InnerText);
                            break;
                        case "ShadowCopyDirectories":
                            rv.ShadowCopyDirectories = SafeTrim(el.InnerText);
                            break;
                        case "ShadowCopyFiles":
                            rv.ShadowCopyFiles = SafeTrim(el.InnerText);
                            break;
                        case "ShouldExcludeApplicationBaseFromAssemblyProbe":
                            rv.ShouldExcludeApplicationBaseFromAssemblyProbe = bool.Parse(SafeTrim(el.InnerText));
                            break;
                        default:
                            throw new InvalidOperationException("Unrecognized element in app domain setup: " + el.Name);
                    }
                }
            }

            rv.ValidatePrivateBinPaths();
            return rv;
        }
Exemplo n.º 6
0
 static int RunInNewDomain(AppDomainParameters parms, string[] commandLineArguments)
 {
     var appDomainSetup = new AppDomainSetup();
     parms.CopyTo(appDomainSetup);
     return RunInNewDomain(appDomainSetup, commandLineArguments);
 }