Some test cases may take a long time and should provide a Cancel option. Cancel is implemented by implementing the ICancellable interface (part of Yats Native test repository manager).
The following example is a Delay test that simply sleeps for a specified time or stops immediately when canceled:
public class DelayTest : IYatsTestCase, ICancellable { TimeSpan delay; public TimeSpan Delay { get {return delay;} set {delay = value;} } public DelayTest () { } #region IYatsTestCase Members protected AutoResetEvent waitFor = new AutoResetEvent( false ); public ITestResult Execute() { if(waitFor.WaitOne( delay ) == false) { return new TestResult( ResultEnum.PASS ); } else { return new TestResult( ResultEnum.CANCELED ); } } #endregion #region ICancellable Members public void Cancel() { waitFor.Set( ); } #endregion }