public void DisposeShouldSetTestHostShutdownOnIssueWithAppDomainUnload()
        {
            // Arrange
            var frameworkHandle   = new Mock <IFrameworkHandle>();
            var testableAppDomain = new Mock <IAppDomain>();

            testableAppDomain.Setup(ad => ad.CreateDomain(It.IsAny <string>(), It.IsAny <Evidence>(), It.IsAny <AppDomainSetup>())).Returns(AppDomain.CurrentDomain);
            testableAppDomain.Setup(ad => ad.Unload(It.IsAny <AppDomain>())).Throws(new CannotUnloadAppDomainException());
            var sourceHost = new TestSourceHost(typeof(DesktopTestSourceHostTests).Assembly.Location, null, frameworkHandle.Object, testableAppDomain.Object);

            sourceHost.CreateInstanceForType(typeof(DesktopTestSourceHostTests), null);

            // Act
            sourceHost.Dispose();

            // Assert
            frameworkHandle.VerifySet(fh => fh.EnableShutdownAfterTestRun = true);
        }
        public void CreateInstanceForTypeShouldCreateTheTypeInANewAppDomain()
        {
            // Setup
            DummyClass dummyclass         = new DummyClass();
            int        currentAppDomainId = dummyclass.AppDomainId;

            TestSourceHost sut = new TestSourceHost(Assembly.GetExecutingAssembly().Location, null, null);

            // Execute
            var expectedObject = sut.CreateInstanceForType(typeof(DummyClass), null) as DummyClass;

            int newAppDomainId = currentAppDomainId + 10;  // not equal to currentAppDomainId

            if (expectedObject != null)
            {
                newAppDomainId = expectedObject.AppDomainId;
            }

            // Assert
            Assert.AreNotEqual(currentAppDomainId, newAppDomainId);
        }