📄 maxtimetestcase.cs
字号:
// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System;
using System.Reflection;
namespace NUnit.Core.Extensions
{
/// <summary>
/// Summary description for MaxTimeTestCase.D:\Dev\NUnit\nunit-2.4\samples\Extensibility\Core\SampleFixtureExtension\Tests\SampleFixtureExtensionTests.cs
/// </summary>
public class MaxTimeTestCase : TestCase
{
private TestCase testCase;
private int maxTime = 0;
public MaxTimeTestCase( TestCase testCase, int maxTime )
: base( (TestName)testCase.TestName.Clone() )
{
// We give it a different test id to avoid confusion
// when debugging - even though it's not strictly
// necessary in this case.
this.TestName.TestID = new TestID();
this.testCase = testCase;
this.maxTime = maxTime;
}
public override void Run(TestCaseResult result)
{
testCase.Run( result );
if ( result.IsSuccess )
{
int elapsedTime = (int)(result.Time * 1000);
if ( elapsedTime > maxTime )
result.Failure( string.Format( "Elapsed time of {0}ms exceeds maximum of {1}ms", elapsedTime, maxTime ), null );
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -