Exemplo n.º 1
0
 public void CloseTest()
 {
     try
     {
         testController.CloseTest();
     }
     catch (Exception e)
     {
         outputWindow21.WriteLine("Exception in closing test...");
         outputWindow21.WriteLine(BaseUtils.GetExceptionInfo(e));
     }
 }
Exemplo n.º 2
0
        public ITest LoadPlug(AppDomain appDomain, string assemblyFile, string classname)
        {
            ITest             test       = null;
            PlugLoadEventArgs loadEvent1 = new PlugLoadEventArgs();

            loadEvent1.PlugName      = classname;
            loadEvent1.AppDomainName = appDomain.FriendlyName;
            loadEvent1.AssemblyName  = assemblyFile;

            if (LoadingPlug != null)
            {
                LoadingPlug(this, loadEvent1);
            }

            try
            {
                //Assembly assembly = Assembly.LoadFrom(appDomain.BaseDirectory + assemblyName + ".dll");
                //test = (ITest)assembly.CreateInstance(classname);
                test = (ITest)appDomain.CreateInstanceFromAndUnwrap(assemblyFile, classname);

                if (test != null)
                {
                    if (test is MarshalByRefObject && appDomain != AppDomain.CurrentDomain)
                    {
                        sponsorer.Register((MarshalByRefObject)test);
                    }

                    //TODO: setOutput here...
                    loadEvent1.TestName = test.Name;

                    if (PlugLoaded != null)
                    {
                        PlugLoaded(this, loadEvent1);
                    }

                    test.InitTest();
                }
            }
            catch (Exception ex)
            {
                //addException(ex);
                loadEvent1.ExceptionInfo = BaseUtils.GetExceptionInfo(ex);

                if (PlugLoadException != null)
                {
                    PlugLoadException(this, loadEvent1);
                }
            }

            return(test);
        }
Exemplo n.º 3
0
        public void CloseTest()
        {
            TestLifeCycleEventArgs tlce = new TestLifeCycleEventArgs(test);

            try
            {
                test.Closing();
            }
            catch (Exception e)
            {
                tlce.ExceptionInfo = BaseUtils.GetExceptionInfo(e);
                ExceptionInTest(this, tlce);
            }
        }
Exemplo n.º 4
0
 public void Execute()
 {
     try
     {
         //TODO: There should be no prepare params.
         //The param and UI should be in sync automatically.
         PrepareParams();
         testController.ExecuteTest();
     }
     catch (Exception e)
     {
         outputWindow21.WriteLine("Exception in executing test...");
         outputWindow21.WriteLine(BaseUtils.GetExceptionInfo(e));
     }
 }
Exemplo n.º 5
0
        //public void StartExecute(object testobj)
        public void StartExecute()
        {
            TestLifeCycleEventArgs tlce = new TestLifeCycleEventArgs(test);

            TestStarted(this, tlce);

            try
            {
                test.ExecuteThis();
            }
            catch (Exception e)
            {
                tlce.ExceptionInfo = BaseUtils.GetExceptionInfo(e);
                ExceptionInTest(this, tlce);
            }
            TestFinished(this, tlce);
        }
Exemplo n.º 6
0
        public ITest[] LoadAllPlugs(IPlugLoadInfo info)
        {
            //resetMessages();
            ArrayList tests = new ArrayList();

            string assemblyName  = null;
            string appDomainName = null;

            try
            {
                string[] assemblies = info.GetAssemblyFiles();
                for (int i = 0; i < assemblies.Length; i++)
                {
                    assemblyName  = assemblies[i];
                    appDomainName = info.GetAppDomainName(assemblies[i]);

                    AppDomain appDomain = LoadAppDomain(appDomainName);
                    string[]  testcases = info.GetTestsFromAssembly(assemblyName);

                    LoadAllPlugs(assemblyName, appDomain, testcases, tests);
                }
            }
            catch (Exception e)
            {
                PlugLoadEventArgs loadEvent = new PlugLoadEventArgs();
                loadEvent.AppDomainName = appDomainName;
                loadEvent.AssemblyName  = assemblyName;
                loadEvent.ExceptionInfo = BaseUtils.GetExceptionInfo(e);

                if (PlugLoadException != null)
                {
                    PlugLoadException(this, loadEvent);
                }
            }

            //message += "\n\nDone !\n\n";
            ITest[] ret = new ITest[tests.Count];
            for (int i = 0; i < tests.Count; i++)
            {
                ret[i] = (ITest)tests[i];
            }
            //return (ITest[])tests.ToArray(typeof(ITest));
            return(ret);
        }
Exemplo n.º 7
0
        private bool Unload(ref AppDomain appDomain)
        {
            bool success = false;

            PlugLoadEventArgs plea = new PlugLoadEventArgs();
            string            name = appDomain.FriendlyName;

            plea.AppDomainName = name;//TODO: check this !

            if (UnloadingAppDomain != null)
            {
                UnloadingAppDomain(this, plea);
            }

            try
            {
                if (appDomain != null)
                {
                    AppDomain.Unload(appDomain);
                    appDomain = null;
                    appDomainTable.Remove(name);

                    if (AppDomainUnloaded != null)
                    {
                        AppDomainUnloaded(this, plea);
                    }
                }
            }
            catch (Exception e)
            {
                plea.ExceptionInfo = BaseUtils.GetExceptionInfo(e);

                if (AppDomainUnloaded != null)
                {
                    AppDomainUnloaded(this, plea);
                }

                success = false;
            }

            return(success);
        }
Exemplo n.º 8
0
        public ITest LoadPlug(string appDomainName, string assemblyFile, string classname)
        {
            try
            {
                AppDomain appDomain = LoadAppDomain(appDomainName);
                return(LoadPlug(appDomain, assemblyFile, classname));
            }
            catch (Exception e)
            {
                PlugLoadEventArgs loadEvent = new PlugLoadEventArgs();
                loadEvent.AppDomainName = appDomainName;
                loadEvent.AssemblyName  = assemblyFile;
                loadEvent.ExceptionInfo = BaseUtils.GetExceptionInfo(e);

                if (PlugLoadException != null)
                {
                    PlugLoadException(this, loadEvent);
                }
            }
            return(null);
        }
Exemplo n.º 9
0
 private void ApplicationThreadException(object sender, ThreadExceptionEventArgs e)
 {
     outputWindowLog.WriteLine("Exception in Plugster");
     outputWindowLog.WriteLine(BaseUtils.GetExceptionInfo(e.Exception));
     MessageBox.Show(e.Exception.Message, "An exception occurred(See logs for more details):", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }