| PropertyChangedAssertionsRaised_PropertyChangedT Method (SmartAssertPlaceHolder, T, String) |
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.12.0
Syntax public static Assertion Raised_PropertyChanged<T>(
this SmartAssertPlaceHolder _,
T instance,
params string[] propertyNames
)
where T : INotifyPropertyChanged
<ExtensionAttribute>
Public Shared Function Raised_PropertyChanged(Of T As INotifyPropertyChanged) (
_ As SmartAssertPlaceHolder,
instance As T,
ParamArray propertyNames As String()
) As Assertion
public:
[ExtensionAttribute]
generic<typename T>
where T : INotifyPropertyChanged
static Assertion^ Raised_PropertyChanged(
SmartAssertPlaceHolder^ _,
T instance,
... array<String^>^ propertyNames
)
[<ExtensionAttribute>]
static member Raised_PropertyChanged :
_ : SmartAssertPlaceHolder *
instance : 'T *
propertyNames : string[] -> Assertion when 'T : INotifyPropertyChanged
Parameters
- _
- Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions. - instance
- Type: T
The instance for which the property/indexer should change. - propertyNames
- Type: SystemString
The names of the property/indexer that should change.
Type Parameters
- T
- The type of the property/indexer that should change.
Return Value
Type:
AssertionThe 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).
Exceptions Remarks
This
Assertion ensures that:
- Before the Act -
Nothing special.
- During the Act -
Ensures the PropertyChanged event is raised.
The PropertyName is one of
propertyNames;
otherwise a SmartTestException is thrown.
Note that you have to repeat names if the event is raised multiple times for the same property.
- After the Act -
If the event is not raised, a SmartTestException is thrown.
Examples
In this example, the Smart Assertion verifies that the
PropertyChanged
event is raised twice, once for
MyProperty and once for
OtherProperty, in any order.
[Test]
public void MyMethodTest()
{
var mc = new MyClass();
RunTest( ValidValue.IsValid,
() => mc.MyMethod(),
SmartAssert.Raised_PropertyChanged( mc, nameof(MyClass.MyProperty), nameof(MyClass.OtherProperty) ) );
}
See Also