1 // ***********************************************************************
2 // Copyright (c) 2010 Charlie Poole
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // ***********************************************************************
25 #define NUNIT_FRAMEWORK
29 using System.Threading;
31 namespace NUnit.Framework.Internal.Commands
34 /// TestCommand is the abstract base class for all test commands
35 /// in the framework. A TestCommand represents a single stage in
36 /// the execution of a test, e.g.: SetUp/TearDown, checking for
37 /// Timeout, verifying the returned result from a method, etc.
39 /// TestCommands may decorate other test commands so that the
40 /// execution of a lower-level command is nested within that
41 /// of a higher level command. All nested commands are executed
42 /// synchronously, as a single unit. Scheduling test execution
43 /// on separate threads is handled at a higher level, using the
46 public abstract class TestCommand
49 /// Construct a TestCommand for a test.
51 /// <param name="test">The test to be executed</param>
52 public TestCommand(Test test)
57 #region Public Methods
60 /// Gets the test associated with this command.
62 public Test Test { get; private set; }
65 /// Runs the test in a specified context, returning a TestResult.
67 /// <param name="context">The TestExecutionContext to be used for running the test.</param>
68 /// <returns>A TestResult</returns>
69 public abstract TestResult Execute(TestExecutionContext context);
73 #region tronghieu.d - Declear ManualResetEvent object for block current thread to handle result from invoking test method.
75 public ManualResetEvent _testMethodRunComplete = new ManualResetEvent(false);