Exemple #1
0
        static WebTestResourcesSetupAttribute.SetupHandler CheckResourcesSetupHandler()
        {
            // It is assumed WebTest is included in the same assembly which contains the
            // tests themselves
            object[] attributes = typeof(WebTest).Assembly.GetCustomAttributes(typeof(WebTestResourcesSetupAttribute), true);
            if (attributes == null || attributes.Length == 0)
            {
                return(null);
            }

            WebTestResourcesSetupAttribute attr = attributes [0] as WebTestResourcesSetupAttribute;

            if (attr == null)
            {
                return(null);
            }

            return(attr.Handler);
        }
Exemple #2
0
		public static void SetupHosting (WebTestResourcesSetupAttribute.SetupHandler resHandler)
		{
			if (host == null)
				host = AppDomain.CurrentDomain.GetData (HOST_INSTANCE_NAME) as MyHost;
			if (host != null)
				CleanApp ();
			if (resHandler == null)
				resHandler = CheckResourcesSetupHandler ();
			if (resHandler == null)
				CopyResources ();
			else
				resHandler ();
			
			foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies ())
				LoadAssemblyRecursive (ass);

			foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies ())
				CopyAssembly (ass, binDir);

			host = (MyHost) ApplicationHost.CreateApplicationHost (typeof (MyHost), VIRTUAL_BASE_DIR, baseDir);
			AppDomain.CurrentDomain.SetData (HOST_INSTANCE_NAME, host);
			host.AppDomain.SetData (HOST_INSTANCE_NAME, host);
 			host.AppDomain.DomainUnload += new EventHandler (_unloadHandler.OnUnload);
		}