toContainOnly
Expects that the subject of this
expectation (a Map) contains only (in any order) a key as defined by keyValuePair's Pair.first with a corresponding value as defined by keyValuePair's Pair.second -- optionally the same assertions are created for the otherPairs.
Delegates to toContain.inAnyOrder.only.entries(keyValuePair, *otherPairs)
Return
an Expect for the subject of this
expectation.
Since
0.17.0
Samples
expect(mapOf(1 to "a")).toContainOnly(1 to "a")
fails { // because the map contains key 2 with value "b" in addition
expect(mapOf(1 to "a", 2 to "b")).toContainOnly(1 to "a")
}
Expects that the subject of this
expectation (a Map) contains only (in any order) a key as defined by keyValue's KeyValue.key with a corresponding value which either holds all assertions keyValue's KeyValue.valueAssertionCreatorOrNull creates or needs to be null
in case KeyValue.valueAssertionCreatorOrNull is defined as null
-- optionally the same assertions are created for the otherKeyValues.
Delegates to toContain.inAnyOrder.only.entries(keyValue, *otherKeyValues)
Return
an Expect for the subject of this
expectation.
Since
0.17.0
Samples
expect(mapOf(1 to "a"))
.toContainOnly(KeyValue(1) { // subject inside this expectation-group is of type String (actually "a")
toEqual("a")
})
fails {
expect(mapOf(1 to "a", 2 to "b"))
.toContainOnly(KeyValue(1) { // subject inside this expectation-group is of type String (actually "a")
toEqual("a")
}) // fails because the map contains key 2 with value "b" in addition
}