| NotChangedAssertionsNotChanged Method (SmartAssertPlaceHolder, Object, NotChangedKind) |
Creates an
Assertion that ensure object properties/fields did not change in the Act part of your
test.
Namespace:
SmartTests.Assertions
Assembly:
SmartTests (in SmartTests.dll) Version: 1.12.0
Syntax public static Assertion NotChanged(
this SmartAssertPlaceHolder _,
Object instance,
NotChangedKind kind = NotChangedKind.PublicProperties
)
<ExtensionAttribute>
Public Shared Function NotChanged (
_ As SmartAssertPlaceHolder,
instance As Object,
Optional kind As NotChangedKind = NotChangedKind.PublicProperties
) As Assertion
public:
[ExtensionAttribute]
static Assertion^ NotChanged(
SmartAssertPlaceHolder^ _,
Object^ instance,
NotChangedKind kind = NotChangedKind::PublicProperties
)
[<ExtensionAttribute>]
static member NotChanged :
_ : SmartAssertPlaceHolder *
instance : Object *
?kind : NotChangedKind
(* Defaults:
let _kind = defaultArg kind NotChangedKind.PublicProperties
*)
-> Assertion
Parameters
- _
- Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions. - instance
- Type: SystemObject
The instance for which the properties/fields should not change. - kind (Optional)
- Type: SmartTests.AssertionsNotChangedKind
The kind of tested members and their visibility. Default value is
PublicProperties
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 Exception | Condition |
---|
SmartTestException |
If any member, of instance, described by kind has changed.
|
Remarks
This
Assertion ensures that:
- Before the Act -
Nothing special.
- After the Act -
If any of the specified members (using kind) has changed, a
SmartTestException is thrown.
Examples
In this example, the Smart Assertion verifies that no property nor field of
other changed while invoking
CopyFrom.
[Test]
public void CopyFromTest()
{
var mc = new MyClass();
var other = new MyClass();
RunTest( ValidValue.IsValid,
() => mc.CopyFrom( other ),
SmartAssert.NotChanged( other, NotChangedKind.All ) );
}
See Also