-
Notifications
You must be signed in to change notification settings - Fork 19
Comparison
Robert Wagner edited this page Sep 12, 2017
·
2 revisions
By default a simple string comparison is used to compare the received
and approved
values. This can be customised by:
Implementing IComparer<string>
:
public class CustomComparer : IComparer<string>
{
public CompareResult Compare(string received, string approved)
{
return received == approved
? CompareResult.Pass()
: CompareResult.Fail("Strings differ");
}
}
configuration = configuration.UsingComparer(new CustomComparer());
A delegate that throws an exception (example uses FluentAssertions)
configuration =
configuration.UsingComparer((recieved, approved) => recieved.Should().Be(approved));
A delegate that returns a CompareResult
configuration =
configuration.UsingComparer(
(recieved, approved) => received == approved
? CompareResult.Pass()
: CompareResult.Fail("Strings differ");
);