//-------------------< loader proxy instance by using ChildAppDomain >------------------------------ public LoaderProxy getLoaderProxyInstance() { childAppDomain.Load("Loader"); ObjectHandle oh = childAppDomain.CreateInstance(typeof(LoaderProxy).Assembly.FullName, typeof(LoaderProxy).FullName); LoaderProxy loaderProxy = oh.Unwrap() as LoaderProxy; return(loaderProxy); }
// --------------------< Constructor that initialisies the comm, Environment, and other required classes >----------- MockTestHarness() { initializeEnvironment(); comm = new Comm(EnvironmentSet.address, EnvironmentSet.port); Data = new List <TestRequestData>(); appDomainModule = new AppDomainModule(); prox = new LoaderProxy(); xmlParse = new XmlParser(); rcvThread = new Thread(rcvThreadProc); rcvThread.Start(); }
//-------------------< start TestHarness Processing and loads the loader to ChildAppDomain >----------- public string startTestProcessing() { ArrayList testLog = new ArrayList(); if (Data.Count > 0) { int i = 0; AppDomain childAppDomain = appDomainModule.createAppDomain(Data[0].authorName, TestHarness.root); Console.WriteLine("\n=====================Using AppDomains to load test libraries====================="); LoaderProxy loaderProxy = appDomainModule.getLoaderProxyInstance(); try { string[] files = Directory.GetFiles(TestHarness.root, "*.dll"); loaderProxy.loadAllAssemblies(files); } catch (Exception e) { Console.Write("Exception directory path incorrect{0}", e.Message); } bool tdCount = loaderProxy.createInstaceforTesting(); if (tdCount) { testLog = loaderProxy.run(); try { tclientMessage = loaderProxy.loaderProxyMessage(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } appDomainModule.unloadAppDomain(childAppDomain); Console.Write("\n Deleting directory that is created for test request directory Name" + TestHarness.root); try { Directory.Delete(Path.GetFullPath(TestHarness.root), true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } foreach (TestRequestData tlog in Data) { tlog.logInfo = (String)testLog[i]; i = i + 1; } // <--------------------------Creates Test Log ---------------------------------> tlogmesssage = xmlParse.XmlCreation("TestLog", Data); } Data.Clear(); return(tlogmesssage); }
//----------------< Test-stub >-------------------------------------------------------------- #if (Test_AppDomainModule) static void Main(string[] args) { AppDomainmodule appDomainModule = new AppDomainModule(); AppDomain childAppDomain = appDomainModule.createAppDomain(authorName, privateBinPath); LoaderProxy loaderProxy = appDomainModule.getLoaderProxyInstance(); }