~nunit-core/nunitv2/2.5

« back to all changes in this revision

Viewing changes to src/NUnitFramework/core/RemoteTestRunner.cs

  • Committer: jnewkirk
  • Date: 2002-07-10 20:00:13 UTC
  • Revision ID: vcs-imports@canonical.com-20020710200013-j8us5mbi0usp7p02
initialĀ load

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Copyright (C) 2002. James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
 
3
//
 
4
namespace Nunit.Core
 
5
{
 
6
        using System;
 
7
        using System.IO;
 
8
        using System.Reflection;
 
9
        using System.Runtime.Remoting;
 
10
 
 
11
        /// <summary>
 
12
        /// Summary description for RemoteTestRunner.
 
13
        /// </summary>
 
14
        public class RemoteTestRunner : MarshalByRefObject
 
15
        {
 
16
                private TestSuite suite;
 
17
                private string fullName;
 
18
                private Nunit.Core.EventListener handler;
 
19
                private string assemblyName;
 
20
                private TextWriter stdOutWriter;
 
21
                private TextWriter stdErrWriter;
 
22
 
 
23
                public RemoteTestRunner(string assemblyName, Nunit.Core.EventListener handler, TextWriter stdOutWriter, TextWriter stdErrOut)
 
24
                {
 
25
                        this.assemblyName = assemblyName;
 
26
                        suite = TestSuiteBuilder.Build(assemblyName);
 
27
                        TestName = suite.FullName;
 
28
 
 
29
                        this.handler = handler;
 
30
                        this.stdErrWriter = stdErrOut;
 
31
                        this.stdOutWriter = stdOutWriter;
 
32
                }
 
33
 
 
34
                public TestResult Run()
 
35
                {
 
36
                        Console.SetOut(stdOutWriter);
 
37
                        Console.SetError(stdErrWriter);
 
38
 
 
39
                        Test test = FindByName(suite, fullName);
 
40
                        TestResult result = test.Run(handler);
 
41
                        return result;
 
42
                }
 
43
 
 
44
                private Test FindByName(Test test, string fullName)
 
45
                {
 
46
                        if(test.FullName.Equals(fullName)) return test;
 
47
                        
 
48
                        Test result = null;
 
49
                        if(test is TestSuite)
 
50
                        {
 
51
                                TestSuite suite = (TestSuite)test;
 
52
                                foreach(Test testCase in suite.Tests)
 
53
                                {
 
54
                                        result = FindByName(testCase, fullName);
 
55
                                        if(result != null) break;
 
56
                                }
 
57
                        }
 
58
 
 
59
                        return result;
 
60
                }
 
61
 
 
62
                public string TestName 
 
63
                {
 
64
                        get { return fullName; }
 
65
                        set { fullName = value; }
 
66
                }
 
67
                        
 
68
                public Test Test
 
69
                {
 
70
                        get 
 
71
                        { return suite; }
 
72
                }
 
73
 
 
74
        }
 
75
}