MaxTimeCommand
TODO: Documentation needed for class
using NUnit.Framework.Interfaces;
using System.Diagnostics;
namespace NUnit.Framework.Internal.Commands
{
public class MaxTimeCommand : AfterTestCommand
{
public MaxTimeCommand(TestCommand innerCommand, int maxTime)
: base(innerCommand)
{
AfterTest = delegate(TestExecutionContext context) {
double duration = (double)(Stopwatch.GetTimestamp() - context.StartTicks) / (double)Stopwatch.Frequency;
TestResult currentResult = context.CurrentResult;
currentResult.Duration = duration;
if (currentResult.ResultState == ResultState.Success) {
double num = currentResult.Duration * 1000;
if (num > (double)maxTime)
currentResult.SetResult(ResultState.Failure, $"""{num}""{maxTime}""");
}
};
}
}
}