PropertyChangedAssertionsRaised_PropertyChangedT Method (SmartAssertPlaceHolder, T, String, Object) |
Namespace: SmartTests.Assertions
public static Assertion Raised_PropertyChanged<T>( this SmartAssertPlaceHolder _, T instance, string propertyName, Object expectedValue ) where T : INotifyPropertyChanged
Exception | Condition |
---|---|
ArgumentNullException | If instance or propertyName are null. |
BadTestException | If the value of the property is expectedValue before the Act. |
SmartTestException | If the INotifyPropertyChanged event is not raised. If PropertyName is not propertyName in the event handler 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 propertyName; 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, nameof(MyClass.MyProperty), 10 ) ); }