Click or drag to resize

WaitAssertionsWaitContextHandle Method (SmartAssertPlaceHolder, 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.12.0
Syntax
public static Assertion WaitContextHandle(
	this SmartAssertPlaceHolder _,
	double timeout
)

Parameters

_
Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions.
timeout
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).
Exceptions
ExceptionCondition
ArgumentOutOfRangeException If timeout is less than or equal to 0.
Examples

In this example, the WaitContextHandle wait for the implicit wait handle set by SetHandle(ActContext).

[Test]
public void MyMethodTest()
{
  var mc = new MyClass(300);

  RunTest( AnyValue.IsValid,
           ctx => mc.Method( ctx.SetHandle ),
           SmartAssert.Within( 100 ),
           SmartAssert.WaitContextHandle( 1000 ) );

  Assert.IsTrue( mc.Done ); // The method runs the parallel code (ctx.SetHandle) to its end.
  Assert.IsNull( mc.Exception ); // There was no exception in the parallel code thread.
}
See Also