-
Notifications
You must be signed in to change notification settings - Fork 9
FeatureMatcher
grahamrhay edited this page Nov 11, 2010
·
1 revision
#FeatureMatcher
A FeatureMatcher<T, U> allows you to focus in on one part of an object:
public class PostcodeMatcher : FeatureMatcher<Address, string>
{
public PostcodeMatcher(IMatcher<string> subMatcher, string featureDescription)
: base(subMatcher, featureDescription, "Postcode")
{ }
protected override string FeatureValueOf(Address actual)
{
return address.Postcode;
}
}
[Test]
public void Match_postcode()
{
var matchesPostcode = new PostcodeMatcher(Is.EqualTo("N1 5TF"), "Postcode is N1 5TF");
var address = new Address { Postcode = "N15TF" };
Assert.That(address, matchesPostcode);
}