Exemplo n.º 1
0
        //<-----------------------------------------Driver Logic------------------------------------------->
        static void Main(string[] args)
        {
            Console.Write("\n  Demonstrating Robust Test Loader");
            Console.Write("\n ==================================\n");
            TestMockHarness harness = new TestMockHarness();

            TestMockHarness.testersLocation = "../../DLLRepository";
            TestMockHarness.testersLocation = Path.GetFullPath(TestMockHarness.testersLocation);
            string result = harness.loadAndExerciseTesters();

            Console.Write("\n\n  {0}", result);
            Console.Write("\n\n");
        }
Exemplo n.º 2
0
        //----< load assemblies from testersLocation and run their tests >-----

        public string loadAndExerciseTesters()
        {
            Console.WriteLine("--------------------------------------------------------------------------------------------------------");
            Console.WriteLine("Requirement 8 MockTestHarness  loading dll files and displays test status success,failure,exceptions if any"); Console.WriteLine("--------------------------------------------------------------------------------------------------------");
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromComponentLibFolder);

            try
            {
                TestMockHarness loader = new TestMockHarness();

                // 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("TestBuild.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");
        }