Click or drag to resize

NotChangedAssertionsNotChangedExcept Method (SmartAssertPlaceHolder, Object, String)

Creates an Assertion that ensure object public properties of the specified instance did not change, except the specified ones, in the Act part of your test.

Namespace:  SmartTests.Assertions
Assembly:  SmartTests (in SmartTests.dll) Version: 1.8.0
public static Assertion NotChangedExcept(
	this SmartAssertPlaceHolder this,
	Object instance,
	params string[] exceptions


Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions.
Type: SystemObject
The instance for which to test public property changes.
Type: SystemString
The names of the public properties that can change during the Act.

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).
BadTestException If exceptions are not public properties of instance.
SmartTestException If any public property of instance, except the exceptions have changed.
This Assertion ensures that:
  1. Before the Act -

    If names in exceptions are not public properties of instance, a BadTestException is thrown.

  2. After the Act -

    If a public property of instance changed during the Act (except exceptions), a SmartTestException is thrown.

In this example, the Smart Assertion verifies that no public property of other, except CopyCount, changed while calling CopyPropertiesFrom.
public void CopyPropertiesFromTest()
    var mc = new MyClass();
    var other = new MyClass();

    RunTest( ValidValue.IsValid,
             () => mc.CopyPropertiesFrom( other ),
             SmartAssert.NotChangedExcept( other, "CopyCount" ) );
See Also