| WithinAssertionsWithin Method (SmartAssertPlaceHolder, TimeSpan) |
Creates an
Assertion that ensure the Act is done within a specific duration.
Namespace:
SmartTests.Assertions
Assembly:
SmartTests (in SmartTests.dll) Version: 1.12.0
Syntax public static Assertion Within(
this SmartAssertPlaceHolder _,
TimeSpan maximumDuration
)
<ExtensionAttribute>
Public Shared Function Within (
_ As SmartAssertPlaceHolder,
maximumDuration As TimeSpan
) As Assertion
public:
[ExtensionAttribute]
static Assertion^ Within(
SmartAssertPlaceHolder^ _,
TimeSpan maximumDuration
)
[<ExtensionAttribute>]
static member Within :
_ : SmartAssertPlaceHolder *
maximumDuration : TimeSpan -> Assertion
Parameters
- _
- Type: SmartTestsSmartAssertPlaceHolder
The dummy place holder for all Smart Assertions. - maximumDuration
- Type: SystemTimeSpan
The maximum allowed duration of 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 |
---|
SmartTestException |
If the Act part of your test is longer than maximumDuration ms.
|
Remarks For this assertion to be accurate, you have to put it as the first Smart Assertion.
Examples In this example, the Smart Assertion verifies that the MyMethod call takes no longer than 10ms.
[Test]
public void MyMethodTest()
{
var mc = new MyClass();
RunTest( ValidValue.IsValid,
() => mc.MyMethod(),
SmartAssert.Within( TimeSpan.FromMilliseconds( 10 ) ) );
}
See Also