Cool, I've been using the HasPropertyWithValue code as a start. I'm trying to check multiple properties on a custom object. Here's the start I have made:
public class PlayerMatcher extends TypeSafeDiagnosingMatcher {
private var _userNameMatcher:Matcher;
public function PlayerMatcher(player:Player) {
super(Player);
_userNameMatcher.matches(player.userName);
}
override public function matchesSafely(item:Object, mismatchDescription:Description):Boolean {
var matches:Boolean = true;
if (!item) {
mismatchDescription
.appendText('Trying to compare against a null object ')
matches = false;
}
var player:Player = (item as Player);
var userName:String = player.userName;
if (!_userNameMatcher.matches(userName)) {
mismatchDescription
.appendText('userName ')
.appendValue(userName)
.appendText(' ')
.appendMismatchOf(_userNameMatcher, userName);
}
return matches;
}
}
There would be additional matchers in there for each property of this object. How would I go about making the call from the test code (that replaces multiple assertions across two objects?)