static void Main(string[] args)
        {
            Console.Write("\n  Demonstrating Robust Test Loader");
            Console.Write("\n ==================================\n");

            DllLoaderExec loader = new DllLoaderExec();

            string testersLocation;

            if (args.Length > 0)
            {
                testersLocation = args[0];
            }
            else
            {
                testersLocation = loader.GuessTestersParentDir() + "/Testers";
            }

            // convert testers relative path to absolute path

            string absPath;

            absPath = Path.GetFullPath(testersLocation);
            Console.Write("\n  Loading Test Modules from:\n    {0}\n", absPath);

            // run load and tests

            string result = loader.loadAndExerciseTesters(absPath);

            Console.Write("\n\n  {0}", result);
            Console.Write("\n\n");
        }
        //----< run demonstration >--------------------------------------------
        /////////////////////////////////////////////////////////////////////Initiates the test
        public static void InitiateTest()
        {
            System.IO.Directory.CreateDirectory("../../../ThFileStore");
            using (log = new System.IO.StreamWriter(System.IO.Path.Combine(LogFilePath, logFileN + ".txt")))
            {
                log.Write("Test Started at: " + DateTime.Now.ToString() + Environment.NewLine);
                foreach (System.Collections.DictionaryEntry env in Environment.GetEnvironmentVariables())
                {
                    log.WriteLine((string)env.Key + "=" + (string)env.Value);
                }
                log.WriteLine(Environment.NewLine + "loading" + Environment.NewLine);
            }
            Console.Write("\n  Demonstrating Robust Test Loader");
            DllLoaderExec loader = new DllLoaderExec();

            DllLoaderExec.testersLocation = Path.GetFullPath(DllLoaderExec.testersLocation);
            Console.Write("\n  Loading Test Modules from:\n    {0}\n", DllLoaderExec.testersLocation);
            string result = loader.loadAndExerciseTesters();


            Console.WriteLine(result);
            using (log = new System.IO.StreamWriter(System.IO.Path.Combine(LogFilePath, logFileN + ".txt"), true))
            {
                log.WriteLine(DateTime.Now.ToString());
            }
            using (log = new System.IO.StreamWriter(System.IO.Path.Combine(LogFilePath, logFileN + ".txt"), true))
            {
                log.WriteLine(result);
                Console.Write(result);
            }
            Console.WriteLine("\nTest logs generated at {0} ", System.IO.Path.GetFullPath(System.IO.Path.Combine("../../../ThFileStore")));
        }
        static void Main(string[] args)
        {
            DllLoaderExec testharness = new DllLoaderExec();

            //fetch the alreay built dll files to the testers
            testharness.getFiles("*.dll");
            foreach (string file in testharness.files)
            {
                Console.Write("\n  \"{0}\"", file);
            }
            foreach (string file in testharness.files)
            {
                string fileName = Path.GetFileName(file);
                Console.Write("\n  sending \"{0}\" to \"{1}\"", fileName, testharness.TestreceivePath);
                testharness.sendFile(file);
            }
            Console.Write("\n\n");

            Console.Write("\n  Demonstrating Robust Test Loader");
            Console.Write("\n ==================================\n");

            DllLoaderExec.testersLocation = Path.GetFullPath(DllLoaderExec.testersLocation);
            Console.Write("\n  Loading Test Modules from:\n    {0}\n", DllLoaderExec.testersLocation);

            // run load and tests

            string result = testharness.loadAndExerciseTesters();

            Console.Write("\n\n  {0}", result);
            Console.Write("\n\n");
        }
        static void Main(string[] args)
        {
            Console.Title           = "Test Harness";
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.Write("\n  Demonstrating Robust Test Loader");
            Console.Write("\n ==================================\n");

            DllLoaderExec loader = new DllLoaderExec();
        }
        //----< load assemblies from testersLocation and run their tests >-----
        /////////////////////////////////////////////////////////////////////////loads libraries and start tests
        string loadAndExerciseTesters()
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromComponentLibFolder);

            try
            {
                DllLoaderExec loader = new DllLoaderExec();

                files = Directory.GetFiles(testersLocation, "*.dll");


                Console.Write("\n\n============================================================================================");
                foreach (string file in files)

                {
                    Console.Write("\nLoaded file is {0}", file);
                    Console.Write("\n\n============================================================================================");
                    Assembly asm      = Assembly.LoadFile(file);
                    string   fileName = Path.GetFileName(file);
                    Console.Write("\n  loaded {0}", fileName);
                    Type[] types = asm.GetTypes();
                    foreach (Type t in types)
                    {
                        if (t.GetInterface("DllLoaderDemo.ITest", true) != null)
                        {
                            if (!loader.runSimulatedTest(t, asm, logFileN))
                            {
                                Console.Write("\n  test {0} failed to run", t.ToString());

                                using (log = new System.IO.StreamWriter(System.IO.Path.Combine(LogFilePath, logFileN + ".txt"), true))
                                {
                                    log.WriteLine("\n  test {0} failed to run", t.ToString());
                                }
                            }
                            else
                            {
                                Console.Write("\n  test {0} succeeded", t.ToString());
                                using (log = new System.IO.StreamWriter(System.IO.Path.Combine(LogFilePath, logFileN + ".txt"), true))
                                {
                                    log.WriteLine("\n  test {0} succeeded", t.ToString());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("Simulated Testing completed");
        }
Beispiel #6
0
        //----< load assemblies from testersLocation and run their tests >-----

        string loadAndExerciseTesters()
        {
            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.LoadFile(file);
                    string   fileName = Path.GetFileName(file);
                    Console.Write("\n  loaded {0}", fileName);

                    // 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("DllLoaderDemo.ITest", true) != null)
                        {
                            if (!loader.runSimulatedTest(t, asm))
                            {
                                Console.Write("\n  test {0} failed to run", t.ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("Simulated Testing completed");
        }
Beispiel #7
0
        //funcion to initiate tests
        public static void InitiateTest()
        {
            System.IO.Directory.CreateDirectory("../../../TestHarnessStore/TestLogs");
            using (log = new System.IO.StreamWriter(System.IO.Path.Combine(LogFilePath, "TestLogs_" + LogFile + ".txt"), true))
            {
                log.Write("Testing started at: " + DateTime.Now.ToString());
                foreach (System.Collections.DictionaryEntry env in Environment.GetEnvironmentVariables())
                {
                    log.WriteLine((string)env.Key + "=" + (string)env.Value);
                }
                log.WriteLine(Environment.NewLine + "Loading:" + Environment.NewLine);
            }
            Console.Write("\n  Demonstrating Robust Test Loader");
            DllLoaderExec loader = new DllLoaderExec();

            DllLoaderExec.testersLocation = Path.GetFullPath(DllLoaderExec.testersLocation);
            Console.Write("\n  Loading Test Modules from:\n    {0}\n", DllLoaderExec.testersLocation);
            string result = loader.loadAndExerciseTesters();

            Console.Write("\n===============================================================\n");
            Console.Write(result);
            using (log = new System.IO.StreamWriter(System.IO.Path.Combine(LogFilePath, "TestLogs_" + LogFile + ".txt"), true))
            {
                log.WriteLine(Environment.NewLine + result);
            }
            try
            {
                System.IO.File.Copy(System.IO.Path.Combine(LogFilePath, "TestLogs_" + LogFile + ".txt"), System.IO.Path.Combine("../../../TestHarnessStore/TestHarnessSendStore", "TestLogs_" + LogFile + ".txt"), true);
            }
            catch (Exception ex)
            { ex.ToString(); }
            try
            {
                System.IO.File.Delete(System.IO.Path.Combine(LogFilePath, "TestLogs_" + LogFile + ".txt"));
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            Console.WriteLine("\nTest logs generated at {0} ", System.IO.Path.GetFullPath(System.IO.Path.Combine("../../../TestHarnessStore/TestLogs")));
            CleanPath();
        }