Esempio n. 1
0
        /* Process incoming messages and take suitable action*/
        private static void processMessage()
        {
            switch (rcvmsg.command)
            {
            case "ExecuteTests":
            {
                rcvmsg.show();
                if (flag == 0)
                {
                    harness.postMessage(rcvmsg);            //Resend message to receiver queue
                }
                else
                {
                    flag   = 0;
                    folder = rcvmsg.arguments[0];
                    DllLoaderExec loader = new DllLoaderExec();                 //Initialize test file's location
                    DllLoaderExec.testersLocation = "../../../TestHarnessStorage/" + rcvmsg.arguments[0];
                    DllLoaderExec.testersLocation = Path.GetFullPath(DllLoaderExec.testersLocation);
                    Console.WriteLine("\nRequirement: 9");
                    Console.WriteLine("\nLoading Test Modules from:\n    {0}\n", DllLoaderExec.testersLocation);
                    string result = loader.loadAndExerciseTesters();            //Perform Testing
                    Console.WriteLine("\n{0}\n", result);
                    connectRepo();
                }
                break;
            }

            case "Connected":
            {
                rcvmsg.show();
                getFilesHelper("../../../TestHarnessStorage/" + folder, "*.txt");
                try
                {
                    Console.WriteLine("\nRequirement: 9");
                    Console.WriteLine("\nSending test logs to RepoStorage");
                    repo.postFile(logfilename[0], "../../../RepoStorage", "../../../TestHarnessStorage/" + folder);
                }                                               //Send log file to repository
                catch (Exception)
                {
                    Console.WriteLine("\nUnable to copy log file");
                }
                flag = 1;
                deleteStorage("../../../TestHarnessStorage/" + folder);         // delete test harness storage
                break;
            }
            }
        }
Esempio n. 2
0
        //----< load assemblies from testersLocation and run their tests >-----
        public string loadAndExerciseTesters()
        {
            tcount++;
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromComponentLibFolder);
            try
            {
                DllLoaderExec loader = new DllLoaderExec();

                // load each assembly found in testersLocation

                string[] files = Directory.GetFiles(testersLocation, "*.dll");
                foreach (string file in files)
                {
                    //Assembly asm = Assembly.LoadFrom(file);

                    Assembly asm      = Assembly.Load(File.ReadAllBytes(file));
                    string   fileName = Path.GetFileName(file);
                    Console.WriteLine("loaded {0}\n", fileName);

                    // exercise each tester found in assembly

                    Type[] types  = asm.GetTypes();
                    int    testno = 0;
                    foreach (Type t in types)
                    {
                        // if type supports ITest interface then run test

                        if (t.GetInterface("DllLoaderDemo.ITest", true) != null)
                        {
                            if (!loader.runSimulatedTest(t, asm, testno))
                            {
                                Console.WriteLine("test {0} failed to run\n", t.ToString());
                            }
                        }
                        testno++;
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("Simulated Testing completed");
        }