Click or drag to resize

PropertyChangedAssertionsRaised_PropertyChangedT Method (SmartAssertPlaceHolder, ExpressionFuncT)

Creates an Assertion that ensure an object property/indexer changed to a different value in the Act part of your test.

Namespace:  SmartTests.Assertions
Assembly:  SmartTests (in SmartTests.dll) Version: 1.9.0
public static Assertion Raised_PropertyChanged<T>(
	this SmartAssertPlaceHolder this,
	Expression<Func<T>> expression


Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions.
Type: System.Linq.ExpressionsExpressionFuncT
The expression that will change, directly or indirectly, the property/indexer.

Type Parameters

The type of the property/indexer that should change.

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).

If expression is not a MemberExpression with a property.

If the involved instance of expression is not an INotifyPropertyChanged instance.

If the member is not a Property.


If the INotifyPropertyChanged event is not raised.

If PropertyName is not the name of the property/indexer in the Act.
This Assertion ensures that:
  1. Before the Act -

    Nothing special.

  2. During the Act -

    Ensures the PropertyChanged event is raised.

    The PropertyName is the one in the Act; otherwise a SmartTestException is thrown.

  3. After the Act -

    If the event was not raised, a SmartTestException is thrown.


In this example, the Smart Assertion verifies that the PropertyChanged event is raised for the property MyProperty.

public void MyMethodTest()
    var mc = new MyClass();
    RunTest( ValidValue.IsValid,
             () => mc.MyMethod(),
             SmartAssert.Raised_PropertyChanged( () => mc.MyProperty ) );
See Also