| ChangedToAssertionsChangedToT Method (SmartAssertPlaceHolder, ExpressionFuncT, T) |
Creates an
Assertion that ensure an object property/indexer changed in the Act part of
your test.
Namespace:
SmartTests.Assertions
Assembly:
SmartTests (in SmartTests.dll) Version: 1.12.0
Syntax public static Assertion ChangedTo<T>(
this SmartAssertPlaceHolder _,
Expression<Func<T>> after,
T value
)
<ExtensionAttribute>
Public Shared Function ChangedTo(Of T) (
_ As SmartAssertPlaceHolder,
after As Expression(Of Func(Of T)),
value As T
) As Assertion
public:
[ExtensionAttribute]
generic<typename T>
static Assertion^ ChangedTo(
SmartAssertPlaceHolder^ _,
Expression<Func<T>^>^ after,
T value
)
[<ExtensionAttribute>]
static member ChangedTo :
_ : SmartAssertPlaceHolder *
after : Expression<Func<'T>> *
value : 'T -> Assertion
Parameters
- _
- Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions. - after
- Type: System.Linq.ExpressionsExpressionFuncT
The expression involving a property/indexer whose value should change in the Act part of your test.
- value
- Type: T
The value to assign to the property/indexer.
Type Parameters
- T
- The Type of the property/indexer.
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 Examples
In this example, the Smart Assertion verifies that
!Equals(mc.MyProperty,10) before the Act part of your
test (otherwise a
BadTestException is raised) and that
Equals(mc.MyProperty,10) after the Act
(otherwise a
SmartTestException is raised).
[Test]
public void MyMethodTest()
{
var mc = new MyClass();
RunTest(AnyValue.Valid,
() => mc.MyMethod(),
SmartAssert.ChangedTo(() => mc.MyProperty, 10));
}
See Also