public TwoDomainsDriver(bool useGeneratedSerializer, bool useGeneratedDeserializer) { this.useGeneratedDeserializer = useGeneratedDeserializer; this.useGeneratedSerializer = useGeneratedSerializer; // this is just a little hack that allows us to debug TwoDomainTests on one domain // when `PrepareDomains` method is not called; when `PrepareDomains` is called // then these fields are overwritten with proper values testsOnDomain1 = this; testsOnDomain2 = this; }
public void DisposeDomains() { testsOnDomain1 = null; testsOnDomain2 = null; AppDomain.Unload(domain1); AppDomain.Unload(domain2); domain1 = null; domain2 = null; Directory.Delete("domain1", true); Directory.Delete("domain2", true); }
public void PrepareDomains() { foreach(var domain in new [] { "domain1", "domain2" }) { Directory.CreateDirectory(domain); foreach(var file in new[] { "Tests.dll", "Migrant.dll" }) { File.Copy(file, Path.Combine(domain, file), true); } } domain1 = AppDomain.CreateDomain("domain1", null, Path.Combine(Environment.CurrentDirectory, "domain1"), string.Empty, true); domain2 = AppDomain.CreateDomain("domain2", null, Path.Combine(Environment.CurrentDirectory, "domain2"), string.Empty, true); testsOnDomain1 = (TwoDomainsDriver)domain1.CreateInstanceAndUnwrap(typeof(TwoDomainsDriver).Assembly.FullName, typeof(TwoDomainsDriver).FullName); testsOnDomain2 = (TwoDomainsDriver)domain2.CreateInstanceAndUnwrap(typeof(TwoDomainsDriver).Assembly.FullName, typeof(TwoDomainsDriver).FullName); }