Click or drag to resize

SmartTestRunTestT Method (Criteria, ExpressionFuncActContext, T, Assertion)

Executes the Act part of the test, and its related Smart Assertions, that involves implicit declarations for Assertions.

Namespace:  SmartTests
Assembly:  SmartTests (in SmartTests.dll) Version: 1.9.0
Syntax
public static T RunTest<T>(
	Criteria cases,
	Expression<Func<ActContext, T>> act,
	params Assertion[] assertions
)

Parameters

cases
Type: SmartTestsCriteria
The Criteria expression for the tested expression.
act
Type: System.Linq.ExpressionsExpressionFuncActContext, T
A lambda expression representing the tested expression with an ActContext.
assertions
Type: SmartTestsAssertion
The Smart Assertions for this act.

Type Parameters

T
The Type of the expression in the Act part of the test.

Return Value

Type: T
The value of the expression of the act.
Exceptions
ExceptionCondition
SmartTestExceptionIn case a Smart Assertion fails after the act.
BadTestExceptionIn case a Smart Assertion fails before the act.
Remarks
Examples

In this example, the WaitContextHandle(SmartAssertPlaceHolder, Double) 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