本文整理汇总了C#中NUnit.Framework.Internal.Commands.TestCommand类的典型用法代码示例。如果您正苦于以下问题:C# TestCommand类的具体用法?C# TestCommand怎么用?C# TestCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestCommand类属于NUnit.Framework.Internal.Commands命名空间,在下文中一共展示了TestCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUpTearDownCommand
/// <summary>
/// Initializes a new instance of the <see cref="SetUpTearDownCommand"/> class.
/// </summary>
/// <param name="innerCommand">The inner command.</param>
public SetUpTearDownCommand(TestCommand innerCommand)
: base(innerCommand)
{
Guard.ArgumentValid(innerCommand.Test is TestMethod, "SetUpTearDownCommand may only apply to a TestMethod", "innerCommand");
Guard.OperationValid(Test.TypeInfo != null, "TestMethod must have a non-null TypeInfo");
_setUpTearDownItems = CommandBuilder.BuildSetUpTearDownList(Test.TypeInfo.Type, typeof(SetUpAttribute), typeof(TearDownAttribute));
}
示例2: WorkItem
/// <summary>
/// Construct a WorkItem for a particular test.
/// </summary>
/// <param name="test">The test that the WorkItem will run</param>
/// <param name="context">The context to be used for running this test</param>
public WorkItem(Test test, TestExecutionContext context)
{
_test = test;
_context = context.Save();
testResult = test.MakeTestResult();
_command = test.GetTestCommand();
_state = WorkItemState.Ready;
}
示例3: Execute
/// <summary>
/// Runs a TestCommand, sending notifications to a listener.
/// </summary>
/// <param name="command">A TestCommand to be executed.</param>
/// <param name="context">The context in which to execute the command.</param>
/// <returns>A TestResult.</returns>
public static TestResult Execute(TestCommand command)
{
TestResult testResult;
TestExecutionContext.Save();
TestExecutionContext context = TestExecutionContext.CurrentContext;
//context = new TestExecutionContext(context);
context.CurrentTest = command.Test;
context.CurrentResult = command.Test.MakeTestResult();
context.Listener.TestStarted(command.Test);
long startTime = DateTime.Now.Ticks;
try
{
TestSuiteCommand suiteCommand = command as TestSuiteCommand;
if (suiteCommand != null)
testResult = ExecuteSuiteCommand(suiteCommand, context);
//{
// suiteCommand.DoOneTimeSetup();
// foreach (TestCommand childCommand in suiteCommand.Children)
// Execute(childCommand, context);
// suiteCommand.DoOneTimeTearDown();
//}
else
testResult = command.Execute(context);
testResult.AssertCount = context.AssertCount;
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
testResult.Time = time;
context.Listener.TestFinished(testResult);
}
catch (Exception ex)
{
#if !NETCF
if (ex is ThreadAbortException)
Thread.ResetAbort();
#endif
context.CurrentResult.RecordException(ex);
return context.CurrentResult;
}
finally
{
TestExecutionContext.Restore();
//context.ReverseChanges();
//context = context.prior;
}
return testResult;
}
示例4: ApplyChangesToContextCommand
public ApplyChangesToContextCommand(TestCommand innerCommand, IEnumerable<IApplyToContext> changes)
: base(innerCommand)
{
_changes = changes;
}
示例5: SimpleWorkItem
/// <summary>
/// Construct a simple work item for a test.
/// </summary>
/// <param name="test">The test to be executed</param>
public SimpleWorkItem(TestMethod test, FinallyDelegate fd) : base(test, fd)
{
_command = test.MakeTestCommand();
}
示例6: SetUpTearDownCommand
TestCommand ICommandDecorator.Decorate(TestCommand command)
{
return new SetUpTearDownCommand(command);
}
示例7: ApplyDecoratorsToCommand
private TestCommand ApplyDecoratorsToCommand(TestCommand command)
{
CommandDecoratorList decorators = new CommandDecoratorList();
// Add Standard stuff
decorators.Add(new SetUpTearDownDecorator());
// Add Decorators supplied by attributes
foreach (ICommandDecoratorSource source in Method.GetCustomAttributes(typeof(ICommandDecoratorSource), true))
foreach (ICommandDecorator decorator in source.GetDecorators())
decorators.Add(decorator);
// Add Decorators from the parameter set
if (parms != null)
foreach (ICommandDecorator decorator in parms.GetDecorators())
decorators.Add(decorator);
decorators.OrderByStage();
foreach (ICommandDecorator decorator in decorators)
{
command = decorator.Decorate(command);
}
return command;
}
示例8: MaxTimeCommand
/// <summary>
/// Initializes a new instance of the <see cref="MaxTimeCommand"/> class.
/// TODO: Add a comment about where the max time is retrieved.
/// </summary>
/// <param name="innerCommand">The inner command.</param>
public MaxTimeCommand(TestCommand innerCommand)
: base(innerCommand)
{
this.maxTime = Test.Properties.GetSetting(PropertyNames.MaxTime, 0);
}
示例9: TestActionCommand
/// <summary>
/// Initializes a new instance of the <see cref="TestActionCommand"/> class.
/// </summary>
/// <param name="innerCommand">The inner command.</param>
public TestActionCommand(TestCommand innerCommand)
: base(innerCommand)
{
Guard.ArgumentValid(innerCommand.Test is TestMethod, "TestActionCommand may only apply to a TestMethod", "innerCommand");
}
示例10: SimpleWorkItem
/// <summary>
/// Construct a simple work item for a test.
/// </summary>
/// <param name="test">The test to be executed</param>
/// <param name="context">The execution context to be used</param>
public SimpleWorkItem(TestMethod test, TestExecutionContext context) : base(test, context)
{
_command = test.MakeTestCommand();
}
示例11: MaxTimeCommand
TestCommand ICommandDecorator.Decorate(TestCommand command)
{
return new MaxTimeCommand(command);
}
示例12: RepeatedTestCommand
TestCommand ICommandDecorator.Decorate(TestCommand command)
{
return new RepeatedTestCommand(command);
}
示例13: GetTestCommand
/// <summary>
/// Gets a test command to be used in executing this test
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public TestCommand GetTestCommand(ITestFilter filter)
{
if (testCommand == null)
testCommand = runState != RunState.Runnable && runState != RunState.Explicit
? new SkipCommand(this)
: MakeTestCommand(filter);
return testCommand;
}
示例14: SimpleWorkItem
/// <summary>
/// Construct a simple work item for a test command.
/// </summary>
/// <param name="command">The command to be executed</param>
public SimpleWorkItem(TestCommand command) : base(command.Test)
{
_command = command;
}
示例15: TheoryResultCommand
/// <summary>
/// Constructs a TheoryResultCommand
/// </summary>
/// <param name="command">The command to be wrapped by this one</param>
public TheoryResultCommand(TestCommand command) : base(command) { }