https://kotlinlang.org logo
s

sam

04/29/2020, 10:35 PM
Copy code
trait CustomMatchers {
 
   def title(expectedValue: String) =
     new HavePropertyMatcher[Book, String] {
       def apply(book: Book) =
         HavePropertyMatchResult(
           book.title == expectedValue,
           "title",
           expectedValue,
           book.title
         )
     }

   def author(expectedValue: String) = 
     new HavePropertyMatcher[Book, String] {
       def apply(book: Book) =
         HavePropertyMatchResult(
           book.author == expectedValue,
           "author",
           expectedValue,
           book.author
         )
     }
 }