expekt icon indicating copy to clipboard operation
expekt copied to clipboard

Lambda-based assertions for collections

Open ikhramts opened this issue 7 years ago • 0 comments

Borrowing from Fluent Assertions, it would be quite convenient to have lambda-based assertions for collections:

class Thing(val name)
val collection = arrayListOf(Thing("a"), Thing("b"), Thing("c"))

collection.should.contain({ it.name == "a" })

Currently it's possible to replicate this using list extensions, but it is not as readable, and will not give as descriptive message:

collection.firstOrNull({ it.name == "a" }).should.not.be.`null`

ikhramts avatar May 25 '17 16:05 ikhramts