Click or drag to resize

WaitAssertionsWait Method (SmartAssertPlaceHolder, WaitHandle, Double)

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.7.0
public static Assertion Wait(
	this SmartAssertPlaceHolder _,
	WaitHandle evt,
	double timeout


Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions.
Type: System.ThreadingWaitHandle
The WaitHandle to wait for before continuing Smart Assertions validations.
Type: SystemDouble
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).
ArgumentNullException If evt is null.
ArgumentOutOfRangeException If timeout is less than or equal to 0.
BadTestException If you call SetHandle(ActContext), as you provided a evt to wait for.
SmartTestException If the evt is not set within timeout milliseconds.

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

public void MyMethodTest()
    var mc = new MyClass();
    var handle = new ManualResetEvent( false );

    RunTest( ValidValue.IsValid,
             () => mc.MyMethod( () => handle.set() ),
             SmartAssert.Wait( handle, 1000 ) );
See Also