kierans777
02/23/2022, 1:27 AMdata class Person(name: String, address: String)
fun aPerson(name: String, address: String): Matcher<Person> =
object: Matcher<Person> {
override fun test(value: Person): MatcherResult {
if (value.name != name) {
return MatcherResult(false, { "${value.name} should be $name" }, { "${value.name} should not be $name" })
}
if (value.address != address) {
return MatcherResult(false, { "${value.address} should be $address" }, { "${value.address} should not be $address" })
}
return MatcherResult(true, { "person is correct" }, { "person is not correct" })
}
}
Is there a better way that I'm missing?sam
02/23/2022, 1:28 AMkierans777
02/23/2022, 1:30 AMPavel Meledin
02/23/2022, 1:23 PMaPerson
matcher that for instance could accept a matcher that would compare not only for exact equality but that either of fields might contain some sub string or check length of the field, etc.sam
02/23/2022, 1:37 PMsam
02/23/2022, 1:39 PMkierans777
02/23/2022, 10:49 PMMatcherResult
or a success.sam
02/23/2022, 10:50 PM