entriesOf

Finishes the specification of the sophisticated to contain expectation where the subject (a MapLike) needs to contain all entries of the given expectedMapLike where it does not matter in which order they appear.

Delegates to entries which also means that it does not search for unique matches (see entries for more information).

Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed. This function expects MapLike (which is a typealias for Any) to avoid cluttering the API.

Return

an Expect for the subject of this expectation.

Since

0.15.0

Parameters

expectedMapLike

The MapLike whose elements are expected to be contained within this MapLike.

Throws

in case expectedMapLike is not a Map, Sequence or one of the Array types or the given expectedMapLike does not have elements (is empty).

Samples

expect(mapOf(1 to "a", 2 to "b")).toContain.inAnyOrder.entriesOf(mapOf(2 to "b"))

fails { // because the value ("a") of key 1 (which exists in the subject) is not "b"
    expect(mapOf(1 to "a", 2 to "b")).toContain.inAnyOrder.entriesOf(mapOf(1 to "b"))
}

Finishes the specification of the sophisticated to contain expectation where the subject (a MapLike) needs to contain only and all entries of the given expectedMapLike where it does not matter in which order they appear.

Delegates to entries which also means that it does not search for unique matches (see entries for more information).

Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed. This function expects MapLike (which is a typealias for Any) to avoid cluttering the API.

Return

an Expect for the subject of this expectation.

Since

0.15.0

Parameters

expectedMapLike

The MapLike whose elements are expected to be contained within this MapLike.

Throws

in case expectedMapLike is not a Map, Sequence or one of the Array types or the given expectedMapLike does not have elements (is empty).

Samples

expect(mapOf(1 to "a", 2 to "b")).toContain.inAnyOrder.only.entriesOf(
    mapOf(2 to "b", 1 to "a")
)

fails { // because subject has additional entries
    expect(mapOf(1 to "a", 2 to "b")).toContain.inAnyOrder.only.entriesOf(
        mapOf(1 to "a")
    )
}

Finishes the specification of the sophisticated to contain expectation where the subject (a MapLike) needs to contain only and all entries of the given expectedMapLike in the specified order.

Delegates to entries.

Notice that a runtime check applies which assures that only Map and IterableLike (i.e. Iterable, Sequence or one of the Array types) are passed (this can be changed via MapLikeToIterablePairTransformer and IterableLikeToIterableTransformer). This function expects MapLike (which is a typealias for Any) to avoid cluttering the API.

Return

an Expect for the subject of this expectation.

Since

0.15.0

Parameters

report

The lambda configuring the InOrderOnlyReportingOptions -- it is optional where the default InOrderOnlyReportingOptions apply if not specified. since 0.18.0

Throws

in case expectedMapLike is not a Map, Sequence or one of the Array types or the given expectedMapLike does not have elements (is empty).

Samples

expect(mapOf(1 to "a", 2 to "b")).toContain.inOrder.only.entriesOf(
    mapOf(1 to "a", 2 to "b")
)

fails { // because the map entries (which all exist in the subject) do not have the same order
    expect(mapOf(1 to "a", 2 to "b")).toContain.inOrder.only.entriesOf(
        mapOf(
            2 to "b",
            1 to "a",
        )
    )
}