Click or drag to resize

DateTimeExtensionsEqualWithinTolerance Method

Determines if 2 DateTime values contain the same Date and Time to within the specified tolerance. That is, if the tolerance specified is 1 second, the DateTime values would have to be within 1 second of each other to match.

Namespace:  TestHelperExtensions
Assembly:  CBI.TestHelperExtensions (in CBI.TestHelperExtensions.dll) Version: 2.1.0.1
Syntax
public static bool EqualWithinTolerance(
	this DateTime objectUnderTest,
	DateTime comparisonValue,
	TimeSpan tolerance
)

Parameters

objectUnderTest
Type: SystemDateTime
A DateTime representing the primary value being tested.
comparisonValue
Type: SystemDateTime
A DateTime representing the value being compared to the primary value.
tolerance
Type: SystemTimeSpan
A TimeSpan representing the maximum discrepancy between the 2 values for the DateTime values to be considered a match.

Return Value

Type: Boolean
A boolean value indicating if the 2 values are equal within the specified tolerance.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DateTime. 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).
See Also