2
// Copyright (C) 2002. James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
7
using System.Runtime.Remoting;
8
using System.Security.Policy;
9
using System.Reflection;
13
/// Summary description for TestRunner.
15
public class TestRunner
17
private string assemblyName;
18
private Nunit.Core.EventListener eventHandler;
19
private AppDomain runnerDomain;
20
private RemoteTestRunner runner;
21
private string fullName;
22
private TextWriter stdOutWriter;
23
private TextWriter stdErrWriter;
25
public TestRunner(string assemblyName, Nunit.Core.EventListener listener, TextWriter stdOutWriter, TextWriter stdErrWriter)
27
this.assemblyName = assemblyName;
28
this.eventHandler = listener;
29
this.stdErrWriter = stdErrWriter;
30
this.stdOutWriter = stdOutWriter;
34
public void LoadRunner()
36
FileInfo info = new FileInfo(assemblyName);
38
AppDomainSetup setup = new AppDomainSetup();
39
setup.ShadowCopyDirectories = info.DirectoryName;
40
setup.ShadowCopyFiles = "true";
42
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
43
Evidence evidence = new Evidence(baseEvidence);
45
runnerDomain = AppDomain.CreateDomain("RemoteRunnerDomain", evidence, setup);
46
//runnerDomain.ClearShadowCopyPath();
47
ObjectHandle handle = runnerDomain.CreateInstance(
48
typeof(RemoteTestRunner).Assembly.FullName, typeof(RemoteTestRunner).FullName,
50
BindingFlags.Default,null,new object[]{assemblyName,eventHandler,stdOutWriter, stdErrWriter},null,null,null);
51
Object runnerObject = handle.Unwrap();
52
runner = (RemoteTestRunner)runnerObject;
55
public TestResult Run()
59
//Assembly[] assemblies = runnerDomain.GetAssemblies();
60
//foreach(Assembly assembly in assemblies)
61
// Console.Out.WriteLine("{0}", assembly.Location);
62
runner.TestName = fullName;
63
TestResult result = runner.Run();
64
//Console.WriteLine("after");
65
//foreach(Assembly assembly in runnerDomain.GetAssemblies())
66
// Console.Out.WriteLine("{0}", assembly.Location);
79
public string TestName
81
get { return fullName; }
82
set { fullName = value;}