keys
infix fun <K, V, T : Map<out K, V>> Expect<T>.keys(assertionCreator: Expect<Set<K>>.() -> Unit): Expect<T>(source)
Expects that the property Map.keys of the subject of this
expectation holds all assertions the given assertionCreator creates for it and returns an Expect for the current subject of this
expectation.
Return
an Expect for the subject of this
expectation.
Samples
expect(mapOf(1 to "a")) keys { // subject inside this expectation-group is of type Set<Int> (containing 1)
this toEqual setOf(1)
}
fails {
// all expectations are evaluated inside an expectation-group block; for more details:
// https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group
expect(mapOf(1 to "a")) keys { // subject inside this expectation-group is of type Set<Int> (containing 1)
this toEqual setOf(2) // fails because 1 is not equal to 2
this toHaveSize 3 // still evaluated because we use an expectation-group block
// use `.keys.` if you want a fail fast behaviour
}
}
Creates an Expect for the property Map.keys of the subject of this
expectation, so that further fluent calls are assertions about it.
Return
The newly created Expect for the extracted feature.
Samples
expect(mapOf(1 to "a")).keys toContain 1
// | subject is now of type Set<Int> (containing 1)
fails {
// fails because 1 is not equal to 2
expect(mapOf(1 to "a")).keys toContain 2
// | subject is now of type Set<Int> (containing 1)
}