Click or drag to resize

RaiseAssertionsNotRaised Method (SmartAssertPlaceHolder, Object, String)

Creates an Assertion that ensure an standard event is not raised in the Act part of your test.

Namespace:  SmartTests.Assertions
Assembly:  SmartTests (in SmartTests.dll) Version: 1.10.0
public static Assertion NotRaised(
	this SmartAssertPlaceHolder this,
	Object instance,
	string eventName


Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions.
Type: SystemObject
The instance for which the event should not raise.
Type: SystemString
The name of the event that should not raise.

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 eventName is null.
ArgumentException If eventName is empty.
BadTestException If the eventName is not a valid event of the type of the instance.
SmartTestException If the eventName event is raised.
This Assertion ensures that:
  1. Before the Act -

    The eventName exists in the type of instance type; otherwise a BadTestException is thrown.

  2. After the Act -

    If the event was raised, a SmartTestException is thrown.

In this example, the Smart Assertion verifies that the MyEvent event is not raised for mc.
public void MyMethodTest()
    var mc = new MyClass();
    RunTest( ValidValue.IsValid,
             () => mc.MyMethod(),
             SmartAssert.NotRaised( mc.InnerObject, "MyEvent" ) );
See Also