コード例 #1
0
        //----< load assemblies from testersLocation and run their tests >-----
        public string loadAndExerciseTesters(string builderid, List <string> dlllist, string filename)
        {
            filecontent = "";
            filecontent = filecontent + " start  of  log  for  " + filename; filecontent = filecontent + "\n\n";
            //AppDomain currentDomain = AppDomain.CurrentDomain;
            Evidence  adevidence    = AppDomain.CurrentDomain.Evidence;
            AppDomain currentDomain = AppDomain.CreateDomain("MyDomain", adevidence);

            // currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromComponentLibFolder);
            try
            {
                TestHarness loader = new TestHarness();
                testersLocation = Path.GetFullPath(testersLocation + "/" + builderid);
                string[] files = Directory.GetFiles(testersLocation, "*.dll");
                Random   rnd   = new Random();
                foreach (string file in files)
                {
                    int    rval        = rnd.Next(1, 100000);
                    string fileName    = Path.GetFileName(file);
                    string oldfilename = file;
                    string newfilename = testersLocation + "\\" + rval.ToString() + fileName;
                    System.IO.File.Move(oldfilename, newfilename);
                    Assembly asm = Assembly.LoadFile(newfilename);
                    if (dlllist.Contains(fileName))
                    {
                        Console.Write("\n  loaded {0}", fileName); filecontent = filecontent + "\n loaded {0} " + fileName; filecontent = filecontent + "\n";
                        ;            // exercise each tester found in assembly
                        Type[] types = asm.GetTypes();
                        foreach (Type t in types)
                        {
                            // if type supports ITest interface then run test
                            if (t.GetInterface("TestBuild.ITest", true) != null)
                            {
                                if (!loader.runSimulatedTest(t, asm, filename, builderid))
                                {
                                    Console.Write("\n  test {0} failed to run", t.ToString());
                                }
                            }
                            filecontent = filecontent + "\n  test {0} failed to run \n";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            finally
            {
                AppDomain.Unload(currentDomain);
            }

            return("Simulated Testing completed");
        }
コード例 #2
0
        //----< load assemblies from testersLocation and run their tests >-----

        string loadAndExerciseTesters()
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromComponentLibFolder);
            try
            {
                TestHarness loader = new TestHarness();
                // load each assembly found in testersLocation
                string[] files = Directory.GetFiles(testersLocation, "*.dll");
                if (files.Count() > 0)
                {
                    foreach (string file in files)
                    {
                        Assembly asm      = Assembly.Load(File.ReadAllBytes(file));
                        string   fileName = Path.GetFileName(file);
                        Console.Write("\n  loaded {0}", fileName);
                        notifyclient("Loaded " + fileName);
                        Type[] types = asm.GetTypes();
                        foreach (Type t in types)
                        {
                            if (t.GetInterface("Test.IDriver", true) != null)
                            {
                                if (!loader.runSimulatedTest(t, asm))
                                {
                                    Console.Write("\n  test {0} failed to run", t.ToString());
                                    notifyclient("Test " + t.ToString() + "failed to run");
                                }
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("\nNo test libraries generated for testing\n");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("Simulated Testing completed");
        }