Ejemplo n.º 1
0
        public void VerifyAppDomainUnloadTerminatesInstance()
        {
            // By default vstesthost sets the AppDomain root directory
            // to the vstesthost.exe path. We need to change that so
            // our assembly can be found.
            var setup = new AppDomainSetup
            {
                ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
            };

            var otherDomain = AppDomain.CreateDomain("InstanceTest", null, setup);

            CreateInAppDomain <InstanceWrapper>(otherDomain);
            AppDomain.Unload(otherDomain);

            // If unloading the AppDomain didn't terminate the instance
            // this will fail with an InstanceNameInUse error.
            var instanceWrapper = new InstanceWrapper();

            instanceWrapper.Cleanup();
        }