| NotChangedAssertionsNotChangedExcept Method (SmartAssertPlaceHolder, NotChangedKind, String) |
Creates an
Assertion that ensure object properties/fields did not change, except the specified ones,
in the Act part of your test.
Namespace:
SmartTests.Assertions
Assembly:
SmartTests (in SmartTests.dll) Version: 1.12.0
Syntax public static Assertion NotChangedExcept(
this SmartAssertPlaceHolder _,
NotChangedKind kind,
params string[] exceptions
)
<ExtensionAttribute>
Public Shared Function NotChangedExcept (
_ As SmartAssertPlaceHolder,
kind As NotChangedKind,
ParamArray exceptions As String()
) As Assertion
public:
[ExtensionAttribute]
static Assertion^ NotChangedExcept(
SmartAssertPlaceHolder^ _,
NotChangedKind kind,
... array<String^>^ exceptions
)
[<ExtensionAttribute>]
static member NotChangedExcept :
_ : SmartAssertPlaceHolder *
kind : NotChangedKind *
exceptions : string[] -> Assertion
Parameters
- _
- Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions. - kind
- Type: SmartTests.AssertionsNotChangedKind
The kind of members and visibility to check for changes. - exceptions
- Type: SystemString
The names of the properties/fields that can change during the Act.
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 |
---|
BadTestException |
If exceptions are not properties/fields of the instance involve in the Act.
|
SmartTestException |
If any property/field checked (see kind), of the instance involved in the Act, except the
exceptions
have changed.
|
Remarks
This
Assertion ensures that:
- Before the Act -
If names in exceptions are not properties/fields of the instance involved in
the Act, a BadTestException is thrown.
- After the Act -
If a property/field changed during the Act (except exceptions), a
SmartTestException is thrown.
Examples
In this example, the Smart Assertion verifies that no property nor field of
mc, except
MyProperty and
OtherProperty
changed while calling
MyMethod.
[Test]
public void CopyFromTest()
{
var mc = new MyClass();
RunTest( ValidValue.IsValid,
() => mc.MyMethod(),
SmartAssert.NotChangedExcept( NotChangedKind.All, "MyProperty", "OtherProperty" ) );
}
See Also