Click or drag to resize

NotChangedAssertionsNotChanged Method (SmartAssertPlaceHolder, 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.9.0
public static Assertion NotChanged(
	this SmartAssertPlaceHolder this,
	NotChangedKind kind = NotChangedKind.PublicProperties


Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions.
kind (Optional)
Type: SmartTests.AssertionsNotChangedKind
The kind of tested members and their visibility. Default value is PublicProperties

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).
SmartTestException If any member, of the instance involved in the Act, described by kind has changed.
This Assertion ensures that:
  1. Before the Act -

    Nothing special.

  2. After the Act -

    If any of the specified members (using kind) has changed, a SmartTestException is thrown.

In this example, the Smart Assertion verifies that no property nor field of mc changed while invoking MyMethod.
public void CopyFromTest()
    var mc = new MyClass();
    RunTest( ValidValue.IsValid,
             () => mc.MyMethod(),
             SmartAssert.NotChanged( NotChangedKind.All ) );
See Also