Click or drag to resize

SmartTestRunTest Method (Case, ExpressionActionActContext, Assertion)

Executes the Act part of the test and its related Smart Assertions.

Namespace:  SmartTests
Assembly:  SmartTests (in SmartTests.dll) Version: 1.7.0
Syntax
public static void RunTest(
	Case cases,
	Expression<Action<ActContext>> act,
	params Assertion[] assertions
)

Parameters

cases
Type: SmartTestsCase
The Case expression for the tested code.
act
Type: System.Linq.ExpressionsExpressionActionActContext
A lambda expression representing the tested expression with an ActContext.
assertions
Type: SmartTestsAssertion
The Smart Assertions for this act.
Exceptions
ExceptionCondition
SmartTestExceptionIn case a Smart Assertion fails after the act.
BadTestExceptionIn case a Smart Assertion fails before the act.
Remarks
Examples
[Test]
public void ReturnVoidTest()
{
  var mc = new MyClass( 300 );

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

  Assert.IsTrue( result );
  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