-
Notifications
You must be signed in to change notification settings - Fork 20
Custom Comparisons
Derek Greer edited this page Sep 22, 2017
·
2 revisions
ExpectedObjects supports custom comparisons by assigning anonymous properties an instance of an object which implements IComparison
. A static Expect
type is provided which currently supplies the following convenience methods:
Expect.Any<T>()
Expect.Any<T>(Expression<Func<T, bool>> predicateExpression)
Expect.Null()
Expect.NotNull()
Expect.Default<T>()
Expect.NotDefault<T>()
The following example shows how a property can be configured to expect any non-null value:
var expected = new
{
Name = "John Doe",
DateTime = DateTime.Today,
VerificationCode = Expect.NotNull()
}.ToExpectedObject();
For more discussion, see the article Expected Objects Custom Comparisons.