PropertyChangedAssertionsRaised_PropertyChangedT Method (SmartAssertPlaceHolder, ExpressionFuncT, T) |
Namespace: SmartTests.Assertions
public static Assertion Raised_PropertyChanged<T>( this SmartAssertPlaceHolder _, Expression<Func<T>> expression, T expectedValue )
Exception | Condition |
---|---|
BadTestException | 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 value of the expression is expectedValue before the Act. |
SmartTestException | If the INotifyPropertyChanged event is not raised. If PropertyName is not the name of the property/indexer in the Act.If the current value of the property is not expectedValue in the event handler and after the Act. |
The value of the property/indexer IS NOT expectedValue; otherwise a BadTestException is thrown.
Ensures the PropertyChanged event is raised.
The PropertyName is the one in the Act; otherwise a SmartTestException is thrown.
The value of the property/indexer in the PropertyChanged handler is expectedValue; otherwise a SmartTestException is thrown
If the event was not raised, a SmartTestException is thrown.
The value of the property/indexer is expectedValue; otherwise a SmartTestException is thrown.
In this example, the Smart Assertion verifies that the PropertyChanged event is raised for the property MyProperty and the value is 10.
It also ensures that the value is still 10 after the Act.
[Test] public void MyMethodTest() { var mc = new MyClass(); RunTest( ValidValue.IsValid, () => mc.MyMethod(), SmartAssert.Raised_PropertyChanged( () => mc.MyProperty, 10 ) ); }