doc / ch.tutteli.atrium.creating / AssertionContainer

AssertionContainer

interface AssertionContainer<T> (source)

Represents the extension point of the logic level for subjects of type T.

In contrast to expectation functions defined for Expect which usually return Expect, functions defined for AssertionContainer return Assertion so that they can be appended to whatever we want.

Parameters

T - The type of the subject of this expectation.

Properties

components

abstract val components: ComponentFactoryContainer

Do not use yet, this is experimental

maybeSubject

abstract val maybeSubject: Option<T>

Either Some wrapping the subject of an Assertion or None in case a previous subject transformation could not be carried out.

Functions

append

abstract fun append(assertion: Assertion): Expect<T>

Appends the given assertion to this container and returns an Expect which includes it.

appendAsGroup

abstract fun appendAsGroup(assertionCreator: Expect<T>.() -> Unit): Expect<T>

Appends the Assertions the given assertionCreator creates to this container and returns an Expect which includes them.

createAndAppend

open fun createAndAppend(description: String, expected: Any?, test: (T) -> Boolean): Expect<T>
open fun createAndAppend(description: Translatable, expected: Any?, test: (T) -> Boolean): Expect<T>

Creates a DescriptiveAssertion based on the given description, expected and test and appends it to the container.

getImpl

abstract fun <I : Any> getImpl(kClass: KClass<I>, defaultFactory: () -> I): I

Do not use yet, this is experimental and will definitely change in 0.17.0 or 0.18.0.

Extension Properties

changeSubject

val <T> AssertionContainer<T>.changeSubject: SubjectChangerBuilder.KindStep<T>

Entry point to use the SubjectChangerBuilder based on this AssertionContainer.

extractFeature

val <T> AssertionContainer<T>.extractFeature: FeatureExtractorBuilder.DescriptionStep<T>

Entry point to use the FeatureExtractorBuilder based on this AssertionContainer.

featureExtractor

val <T> AssertionContainer<T>.featureExtractor: FeatureExtractor

iterableLikeToIterableTransformer

val AssertionContainer<*>.iterableLikeToIterableTransformer: IterableLikeToIterableTransformer

mapLikeToMapTransformer

val AssertionContainer<*>.mapLikeToMapTransformer: MapLikeToIterablePairTransformer

subjectChanger

val <T> AssertionContainer<T>.subjectChanger: SubjectChanger

Extension Functions

collect

fun <T> AssertionContainer<T>.collect(assertionCreator: Expect<T>.() -> Unit): Assertion

Use this function if you want to make Assertions about a feature or you perform a type transformation or any other action which results in an Expect being created for a different subject and you do not require this resulting Expect.

collectBasedOnSubject

fun <T> AssertionContainer<*>.collectBasedOnSubject(maybeSubject: Option<T>, assertionCreator: Expect<T>.() -> Unit): Assertion

Use this function if you want to make Assertions about a feature or you perform a type transformation or any other action which results in an Expect being created for a different subject and you do not require this resulting Expect.

collectForComposition

fun <T> AssertionContainer<T>.collectForComposition(assertionCreator: Expect<T>.() -> Unit): List<Assertion>

Use this function if you want to collect Assertions and use it as part of another Assertion (e.g. as part of an AssertionGroup).

collectForCompositionBasedOnSubject

fun <T> AssertionContainer<*>.collectForCompositionBasedOnSubject(maybeSubject: Option<T>, assertionCreator: Expect<T>.() -> Unit): List<Assertion>

Use this function if you want to collect Assertions and use it as part of another Assertion (e.g. as part of an AssertionGroup).

createDescriptiveAssertion

fun <T> AssertionContainer<T>.createDescriptiveAssertion(description: Translatable, representation: Any?, test: (T) -> Boolean): Assertion

Creates a DescriptiveAssertion based on the given description, representation and test.

genericSubjectBasedFeature

fun <T, R> AssertionContainer<T>.genericSubjectBasedFeature(provider: (T) -> MetaFeature<R>): FeatureExtractorBuilder.ExecutionStep<T, R>

iterableLikeToIterable

fun <T> AssertionContainer<*>.iterableLikeToIterable(iterableLike: IterableLike): Iterable<T>

Transforms the given iterableLike to an Iterable with an element type T.

iterableLikeToIterableWithoutCheckForElements

fun <T> AssertionContainer<*>.iterableLikeToIterableWithoutCheckForElements(iterableLike: IterableLike): Iterable<T>

Transforms the given iterableLike to an Iterable with an element type T.

manualFeature

fun <T, R> AssertionContainer<T>.manualFeature(description: String, provider: T.() -> R): FeatureExtractorBuilder.ExecutionStep<T, R>

Convenience method to pass a String as description which is wrapped into an Untranslatable instead of passing a Translatable.

mapLikeToIterablePair

fun <K, V> AssertionContainer<*>.mapLikeToIterablePair(mapLike: MapLike): List<Pair<K, V>>

Transforms the given MapLike to Pair<Pair<K, V>, Array<out Pair<K, V>>> with the intention that it can be easily used for a function requiring Pair<K, V>, vararg Pair<K, V>.

mapLikeToVarArgPairs

fun <K, V> AssertionContainer<*>.mapLikeToVarArgPairs(mapLike: MapLike): Pair<Pair<K, V>, Array<out Pair<K, V>>>

Transforms the given MapLike to an Iterable with an element type Pair<K, V>.

toExpect

fun <T> AssertionContainer<T>.toExpect(): Expect<T>

Casts this AssertionContainer back to an Expect so that you can use it in places where an Expect is used.

Inheritors

ExpectInternal

interface ExpectInternal<T> : Expect<T>, AssertionContainer<T>

Sole purpose of this interface is to hide AssertionContainer from newcomers which usually don't have to deal with this.