doc / ch.tutteli.atrium.api.fluent.en_GB / values

values

fun <T : CharSequence> CharSequenceContains.CheckerStep<T, NoOpSearchBehaviour>.values(expected: CharSequenceOrNumberOrChar, vararg otherExpected: CharSequenceOrNumberOrChar): Expect<T> (source)

Finishes the specification of the sophisticated contains assertion where the expected value as well as the otherExpected values shall be searched, using a non disjoint search.

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.

By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. Also notice, that it does not search for unique matches. Meaning, if the input of the search is "a" and expected is defined as "a" and one otherExpected is defined as "a" as well, then both match, even though they match the same sequence in the input of the search. Use an option such as atLeast, atMost and exactly to control the number of occurrences you expect.

Meaning you might want to use: contains.exactly(2).value("a") instead of: contains.atLeast(1).values("a", "a")

Parameters

expected - The value which is expected to be contained within the input of the search.

otherExpected - Additional values which are expected to be contained within the input of the search.

Exceptions

IllegalArgumentException - in case expected or one of the otherExpected is not a CharSequence, Number or Char.

Return
an Expect for the subject of this expectation.

@JvmName("valuesIgnoringCase") fun <T : CharSequence> CharSequenceContains.CheckerStep<T, IgnoringCaseSearchBehaviour>.values(expected: CharSequenceOrNumberOrChar, vararg otherExpected: CharSequenceOrNumberOrChar): Expect<T> (source)

Finishes the specification of the sophisticated contains assertion where the expected value as well as the otherExpected values shall be searched (ignoring case), using a non disjoint search.

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.

By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. Also notice, that it does not search for unique matches. Meaning, if the input of the search is "a" and expected is defined as "a" and one otherExpected is defined as "a" as well, then both match, even though they match the same sequence in the input of the search. Use an option such as atLeast, atMost and exactly to control the number of occurrences you expect.

Meaning you might want to use: contains.ignoringCase.exactly(2).value("a") instead of: contains.ignoringCase.atLeast(1).values("a", "a")

Parameters

expected - The value which is expected to be contained within the input of the search.

otherExpected - Additional values which are expected to be contained within the input of the search.

Exceptions

IllegalArgumentException - in case expected or one of the otherExpected is not a CharSequence, Number or Char.

Return
an Expect for the subject of this expectation.

fun <T : CharSequence> CharSequenceContains.EntryPointStep<T, IgnoringCaseSearchBehaviour>.values(expected: CharSequenceOrNumberOrChar, vararg otherExpected: CharSequenceOrNumberOrChar): Expect<T> (source)

Finishes the specification of the sophisticated contains assertion where the expected value as well as the otherExpected values shall be searched (ignoring case), using a non disjoint search where each need to be contained at least once.

Delegates to atLeast(1).values(expected, otherExpected)

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.

By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. Also notice, that it does not search for unique matches. Meaning, if the input of the search is "a" and expected is defined as "a" and one otherExpected is defined as "a" as well, then both match, even though they match the same sequence in the input of the search.

Parameters

expected - The value which is expected to be contained within the input of the search.

otherExpected - Additional values which are expected to be contained within the input of the search.

Exceptions

IllegalArgumentException - in case expected or one of the otherExpected is not a CharSequence, Number or Char.

Return
an Expect for the subject of this expectation.

fun <E, T> IterableLikeContains.CheckerStep<E, T, InAnyOrderSearchBehaviour>.values(expected: E, vararg otherExpected: E): Expect<T> (source)

Finishes the specification of the sophisticated contains assertion where the subject (an IterableLike) needs to contain the expected value as well as the otherExpected values where it does not matter in which order they appear.

Notice, that it does not search for unique matches. Meaning, if the iterable is setOf('a', 'b') and expected is defined as 'a' and one otherExpected is defined as 'a' as well, then both match, even though they match the same entry. Use an option such as atLeast, atMost and exactly to control the number of occurrences you expect.

Meaning you might want to use: contains.inAnyOrder.exactly(2).values('a') instead of: contains.inAnyOrder.atLeast(1).values('a', 'a')

Parameters

expected - The object which is expected to be contained within this IterableLike.

otherExpected - Additional objects which are expected to be contained within this IterableLike.

Return
an Expect for the subject of this expectation.

Since
0.14.0 -- API existed for Iterable but not for IterableLike.

fun <E, T> IterableLikeContains.EntryPointStep<E, T, InAnyOrderOnlySearchBehaviour>.values(expected: E, vararg otherExpected: E): Expect<T> (source)

Finishes the specification of the sophisticated contains assertion where the subject (an IterableLike) needs to contain only the expected value as well as the otherExpected values where it does not matter in which order.

Note that we might change the signature of this function with the next version which will cause a binary backward compatibility break (see #292 for more information)

Parameters

expected - The value which is expected to be contained within the subject (an IterableLike).

otherExpected - Additional values which are expected to be contained within IterableLike.

Return
an Expect for the subject of this expectation.

Since
0.14.0 -- API existed for Iterable but not for IterableLike.

fun <E, T> IterableLikeContains.EntryPointStep<E, T, InOrderOnlySearchBehaviour>.values(expected: E, vararg otherExpected: E): Expect<T> (source)

Finishes the specification of the sophisticated contains assertion where the subject (an IterableLike) needs to contain only the expected value as well as the otherExpected values in the specified order.

Note that we might change the signature of this function with the next version which will cause a binary backward compatibility break (see #292 for more information)

Parameters

expected - The value which is expected to be contained within the subject (an IterableLike).

otherExpected - Additional values which are expected to be contained within IterableLike.

Return
an Expect for the subject of this expectation.

Since
0.14.0 -- API existed for Iterable but not for IterableLike.

fun <K, V, T : Map<out K, V>> Expect<T>.values(assertionCreator: Expect<Collection<V>>.() -> 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.

expect(mapOf(1 to "a"))
    .values {   // subject inside this block is of type Collection<String> (actually <"a">)
        toBe(setOf("a"))
    }

fails {
    expect(mapOf(1 to "a"))
        .values {   // subject inside this block is of type Collection<String> (actually <"a">)
            toBe(setOf("b"))    // fails because <"a"> is not equal to <"b">
        }
}

Return
an Expect for the subject of this expectation.

val <V, T : Map<*, V>> Expect<T>.values: Expect<Collection<V>> (source)

Creates an Expect for the property Map.values of the subject of this expectation, so that further fluent calls are assertions about it.

expect(mapOf(1 to "a"))
    .values //subject is of type Collection<String> (actually <"a">)
    .contains { // subject inside this block is of type String
        toBe("a")
    }

fails {
    expect(mapOf(1 to "a"))
        .values //subject is of type Collection<String> (actually <"a">)
        .contains { // subject inside this block is of type String
            toBe("b")   // fails because "a" is not equal to "b"
        }
}

Return
The newly created Expect for the extracted feature.