toContainOnlyEntriesOf

fun <K, V : Any, T : Map<out K, V?>> Expect<T>.toContainOnlyEntriesOf(mapLike: MapLike): Expect<T>(source)

Expects that the subject of this expectation (a Map) contains only (in any order) the key-value pairs of the given mapLike.

Delegates to toContain.inAnyOrder.only.entriesOf

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect(mapOf(1 to "a")).toContainOnlyEntriesOf(mapOf(1 to "a"))

fails { // because the map contains key 2 with value "b" in addition
    expect(mapOf(1 to "a", 2 to "b"))
        .toContainOnlyEntriesOf(mapOf(1 to "a"))
}