Click or drag to resize

ChangeAssertionsChangeT Method

Creates an Assertion that ensure relative changes to a property/indexer of an object.

Namespace:  SmartTests.Assertions
Assembly:  SmartTests (in SmartTests.dll) Version: 1.7.0
Syntax
public static Assertion Change<T>(
	this SmartAssertPlaceHolder this,
	Expression<Func<T>> after
)

Parameters

this
Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions.
after
Type: System.Linq.ExpressionsExpressionFuncT
The expressionn involving a property/indexer whose value should be equal to the value of the member only after the Act.

Type Parameters

T
The Type of the property/indexer.

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).
Exceptions
ExceptionCondition
SmartTestException if the property/indexer value AFTER the Act is not the value of the expression after.
Remarks
This Assertion ensures that:
  1. Before the Act -

    Evaluates the after expression.

  2. After the Act -

    Evaluates the after expression stripped of any computation so that there is only a property/indexer call.

    This value should be equal to the previously computed value (after before the Act); otherwise a SmartTestException is thrown.

Examples
In the following example, we expect that the mc.MyList.Count value after the Act is the value of the same property before the Act plus 1.
[Test]
public void AddItemTest()
{
    var mc = new MyClass();

    RunTest( AnyValue.Valid,
             () => mc.AddItem(),
             SmartAssert.Change( () => mc.MyList.Count + 1 ) );
}
See Also