Click or drag to resize

WaitAssertionsWait Method (SmartAssertPlaceHolder, WaitHandle, TimeSpan)

Creates an Assertion that ensure an asynchronous call from the Act is done before continuing Smart Assertions validations.

Namespace:  SmartTests.Assertions
Assembly:  SmartTests (in SmartTests.dll) Version: 1.12.0
Syntax
public static Assertion Wait(
	this SmartAssertPlaceHolder _,
	WaitHandle evt,
	TimeSpan timeout
)

Parameters

_
Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions.
evt
Type: System.ThreadingWaitHandle
The WaitHandle to wait for before continuing Smart Assertions validations.
timeout
Type: SystemTimeSpan
The maximum milliseconds to wait for the handle to be set.

Return Value

Type: Assertion
The newly created Assertion.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type SmartAssertPlaceHolder. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentNullException If evt is null.
ArgumentOutOfRangeException If timeout is less than or equal to 0.
SmartTestException If the evt is not set within timeout.
BadTestException If you call SetHandle(ActContext), as you provided a evt to wait for.
Examples

In this example, the Smart Assertion verifies that the MyMethod call launches a callback within 1s.

[Test]
public void MyMethodTest()
{
    var mc = new MyClass();
    var handle = new ManualResetEvent( false );

    RunTest( ValidValue.IsValid,
             () => mc.MyMethod( () => handle.set() ),
             SmartAssert.Wait( handle, TimeSpan.FromSeconds( 1 ) ) );
}
See Also