1 // ****************************************************************
\r
2 // This is free software licensed under the NUnit license. You
\r
3 // may obtain a copy of the license as well as information regarding
\r
4 // copyright ownership at http://nunit.org/?p=license&r=2.4.
\r
5 // ****************************************************************
\r
10 using System.Collections;
\r
11 using System.Reflection;
\r
14 /// The abstract TestCase class represents a single test case.
\r
15 /// In the present implementation, the only derived class is
\r
16 /// TestMethod, but we allow for future test cases which are
\r
17 /// implemented in other ways.
\r
19 public abstract class TestCase : Test
\r
21 public TestCase( string path, string name ) : base( path, name ) { }
\r
23 public TestCase( MethodInfo method ) : base ( method ) { }
\r
25 public TestCase( TestName testName ) : base ( testName ) { }
\r
27 public override int CountTestCases( ITestFilter filter )
\r
29 if (filter.Pass(this))
\r
35 protected virtual TestCaseResult MakeTestCaseResult()
\r
37 return new TestCaseResult( new TestInfo(this) );
\r
40 public override TestResult Run(EventListener listener, ITestFilter filter)
\r
42 return Run( listener ); // Ignore filter for now
\r
45 public override TestResult Run( EventListener listener )
\r
47 using( new TestContext() )
\r
49 TestCaseResult testResult = MakeTestCaseResult();
\r
51 listener.TestStarted( this.TestName );
\r
52 long startTime = DateTime.Now.Ticks;
\r
54 switch (this.RunState)
\r
56 case RunState.Runnable:
\r
57 case RunState.Explicit:
\r
60 case RunState.Skipped:
\r
61 testResult.Skip(IgnoreReason);
\r
64 case RunState.NotRunnable:
\r
65 case RunState.Ignored:
\r
66 testResult.Ignore(IgnoreReason);
\r
70 long stopTime = DateTime.Now.Ticks;
\r
71 double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
\r
72 testResult.Time = time;
\r
74 listener.TestFinished(testResult);
\r
79 public override string TestType
\r
81 get { return "Test Case"; }
\r
84 public override bool IsSuite
\r
86 get { return false; }
\r
89 public override IList Tests
\r
91 get { return null; }
\r
94 public abstract void Run(TestCaseResult result);
\r