val <K, T : Entry<K, *>> Expect<T>.key: Expect<K>
(source)
Creates an Expect for the property Map.Entry.key of the subject of this
expectation,
so that further fluent calls are assertions about it.
expect(mapOf(1 to "a").entries.first())
.key // subject here is of type Int (actually 1)
.toBe(1)
fails {
expect(mapOf(1 to "a").entries.first())
.key // subject here is of type Int (actually 1)
.toBe(2) // fails because 1 is not equal to 2
}
Return
The newly created Expect for the extracted feature.
fun <K, V, T : Entry<K, V>> Expect<T>.key(assertionCreator: Expect<K>.() -> Unit): Expect<T>
(source)
Expects that the property Map.Entry.key 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.
expect(mapOf(1 to "a").entries.first())
.key { // subject inside this block is of type Int (actually 1)
toBe(1)
}
fails {
expect(mapOf(1 to "a").entries.first())
.key { // subject inside this block is of type Int (actually 1)
toBe(2) // fails because 1 is not equal to 2
}
}
Return
an Expect for the subject of this
expectation.