RaiseAssertionsRaisedT Method (SmartAssertPlaceHolder, String, EventHandlerT) |
Namespace: SmartTests.Assertions
public static Assertion Raised<T>( this SmartAssertPlaceHolder _, string expectedEventName, EventHandler<T> assert ) where T : EventArgs
Exception | Condition |
---|---|
ArgumentNullException | If expectedEventName is null. |
ArgumentException | If expectedEventName is empty. |
BadTestException | If the expectedEventName is not a valid event of the type of the instance involved in the Act. |
SmartTestException | If the expectedEventName event is not raised. |
The expectedEventName exists in the type of the instance involved in the Act type; otherwise a BadTestException is thrown.
Invoke the assert handler, to test specific assertions.
If the event was not raised, a SmartTestException is thrown.
In this example, the Smart Assertion verifies that the MyEvent event is raised for mc.
It also ensure anything you want in the specified handler.
[Test] public void MyMethodTest() { var mc = new MyClass(); RunTest( ValidValue.IsValid, () => mc.MyMethod(), SmartAssert.Raised( "MyEvent", ( sender, args ) => { // Check anything you want when MyEvent is raised. })); }