doc / ch.tutteli.atrium.creating / IAssertionPlant

IAssertionPlant

interface IAssertionPlant<out T : Any> : IAssertionPlantWithCommonFields<T>

Represents a plant for IAssertions and offers the possibility to check all the added assertions.

You can think of it as an IAssertion factory which does more than just factoring but also provides quality assurance capabilities.

Properties

and

open val and: IAssertionPlant<T>

Can be used to separate assertions when using the fluent-style API.

Inherited Properties

commonFields

abstract val commonFields: CommonFields<T>

CommonFields of this plant.

subject

open val subject: T

The subject for which this plant will create/check IAssertions.

Functions

addAssertion

abstract fun addAssertion(assertion: IAssertion): IAssertionPlant<T>

Adds the given assertion to the plant.

checkAssertions

abstract fun checkAssertions(): IAssertionPlant<T>

Checks the so far added IAssertions and reports if one of them fails.

createAndAddAssertion

abstract fun createAndAddAssertion(description: ITranslatable, expected: Any, test: () -> Boolean): IAssertionPlant<T>

Creates an IAssertion based on description, expected and test and adds it to the plant.

Extension Properties

message

val <T : Throwable> IAssertionPlant<T>.message: IAssertionPlant<String>

Creates an IAssertionPlantNullable for the message of the plant's subject (which is an Throwable) and makes the assertion that message isNotNull.

Extension Functions

contains

fun <T : CharSequence> IAssertionPlant<T>.contains(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject contains the expected.

fun <T : CharSequence> IAssertionPlant<T>.contains(expected: CharSequence, vararg otherExpected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject contains the expected and otherExpecteds (if defined).

fun <T : CharSequence> IAssertionPlant<T>.contains(expected: ITranslatable, vararg otherExpected: ITranslatable): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject contains expected's getDefault representation and the getDefault representation of the otherExpected (if defined).

fun <T : CharSequence> IAssertionPlant<T>.contains(expected: Any, vararg otherExpected: Any): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject contains expected's toString representation and the toString representation of the otherExpected (if defined).

containsNot

fun <T : CharSequence> IAssertionPlant<T>.containsNot(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not contain the expected.

fun <T : CharSequence> IAssertionPlant<T>.containsNot(expected: CharSequence, vararg otherExpected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not contain the expected and neither one of the otherExpecteds (if defined).

fun <T : CharSequence> IAssertionPlant<T>.containsNot(expected: ITranslatable, vararg otherExpected: ITranslatable): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject contains expected's getDefault representation and the getDefault representation of the otherExpected (if defined).

fun <T : CharSequence> IAssertionPlant<T>.containsNot(expected: Any, vararg otherExpected: Any): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not contain expected's toString representation and neither one of the otherExpected's toString representation (if defined).

createAssertionsAndCheckThem

fun <T : Any> IAssertionPlant<T>.createAssertionsAndCheckThem(createAssertions: IAssertionPlant<T>.() -> Unit): IAssertionPlant<T>

Uses this plant as receiver of the given createAssertions function and then calls IAssertionPlant.checkAssertions.

endsNotWith

fun <T : CharSequence> IAssertionPlant<T>.endsNotWith(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not end with expected.

endsWith

fun <T : CharSequence> IAssertionPlant<T>.endsWith(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject ends with expected.

hasSize

fun <T : Collection<*>> IAssertionPlant<T>.hasSize(size: Int): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject's Collection.size is size.

isA

fun <TSub : Any> IAssertionPlant<Any>.isA(): IAssertionPlant<TSub>

Makes the assertion that IAssertionPlant.subject is a TSub (the same type or a sub-type).

fun <TSub : Any> IAssertionPlant<Any>.isA(createAssertions: IAssertionPlant<TSub>.() -> Unit): IAssertionPlant<TSub>

Makes the assertion that IAssertionPlant.subject is a TSub (the same type or a sub-type) and if so, uses createAssertions which could create further assertions which are lazily evaluated at the end.

isEmpty

fun <T : CharSequence> IAssertionPlant<T>.isEmpty(): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject.kotlin.text.isEmpty.

isFalse

fun IAssertionPlant<Boolean>.isFalse(): IAssertionPlant<Boolean>

Makes the assertion that IAssertionPlant.subject is false.

isGreaterOrEquals

fun <T> IAssertionPlant<T>.isGreaterOrEquals(expected: T): IAssertionPlant<T> where T : Number, T : Comparable<T>

Makes the assertion that IAssertionPlant.subject is greater than or equals expected.

isGreaterThan

fun <T> IAssertionPlant<T>.isGreaterThan(expected: T): IAssertionPlant<T> where T : Number, T : Comparable<T>

Makes the assertion that IAssertionPlant.subject is greater than expected.

isLessOrEquals

fun <T> IAssertionPlant<T>.isLessOrEquals(expected: T): IAssertionPlant<T> where T : Number, T : Comparable<T>

Makes the assertion that IAssertionPlant.subject is less than or equals expected.

isLessThan

fun <T> IAssertionPlant<T>.isLessThan(expected: T): IAssertionPlant<T> where T : Number, T : Comparable<T>

Makes the assertion that IAssertionPlant.subject is less than expected.

isNotEmpty

fun <T : CharSequence> IAssertionPlant<T>.isNotEmpty(): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject.kotlin.text.isNotEmpty.

isNotSame

fun <T : Any> IAssertionPlant<T>.isNotSame(expected: T): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is not the same instance as expected.

isSame

fun <T : Any> IAssertionPlant<T>.isSame(expected: T): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is the same instance as expected.

isTrue

fun IAssertionPlant<Boolean>.isTrue(): IAssertionPlant<Boolean>

Makes the assertion that IAssertionPlant.subject is true.

its

fun <T : Any, TFeature : Any> IAssertionPlant<T>.its(feature: KProperty0<TFeature>): IAssertionPlant<TFeature>

Creates an IAssertionPlant which immediately evaluates IAssertions using the given feature as subject.

fun <T : Any, TFeature : Any> IAssertionPlant<T>.its(feature: KProperty0<TFeature>, createAssertions: IAssertionPlant<TFeature>.() -> Unit): IAssertionPlant<TFeature>

Creates an IAssertionPlant which lazily evaluates IAssertions using the given feature as subject.

message

fun <T : Throwable> IAssertionPlant<T>.message(createAssertions: IAssertionPlant<String>.() -> Unit): IAssertionPlant<String>

Creates an IAssertionPlantNullable for the message of the plant's subject (which is an Throwable) and makes the assertion that message isNotNull and uses createAssertions which might create further IAssertions which are lazily evaluated at the end.

notToBe

fun <T : Any> IAssertionPlant<T>.notToBe(expected: T): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is not (does not equal) expected.

property

fun <T : Any, TProperty : Any> IAssertionPlant<T>.property(property: KProperty0<TProperty>): IAssertionPlant<TProperty>

Creates an IAssertionPlant which immediately evaluates IAssertions using the given property as subject.

fun <T : Any, TProperty : Any> IAssertionPlant<T>.property(property: KProperty0<TProperty>, createAssertions: IAssertionPlant<TProperty>.() -> Unit): IAssertionPlant<TProperty>

Creates an IAssertionPlant which lazily evaluates IAssertions using the given property as subject.

returnValueOf

fun <T : Any, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction0<TReturnValue>): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which immediately evaluates IAssertions using the value returned by calling method of the subject.

fun <T : Any, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction0<TReturnValue>, createAssertions: IAssertionPlant<TReturnValue>.() -> Unit): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which lazily evaluates IAssertions using the value returned by calling method of the subject.

fun <T : Any, T1, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction1<T1, TReturnValue>, arg1: T1): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which immediately evaluates IAssertions using the value returned by calling method of the subject with arg1.

fun <T : Any, T1, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction1<T1, TReturnValue>, arg1: T1, createAssertions: IAssertionPlant<TReturnValue>.() -> Unit): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which lazily evaluates IAssertions using the value returned by calling method of the subject with arg1.

fun <T : Any, T1, T2, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction2<T1, T2, TReturnValue>, arg1: T1, arg2: T2): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which immediately evaluates IAssertions using the value returned by calling method of the subject with arg1 and arg2.

fun <T : Any, T1, T2, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction2<T1, T2, TReturnValue>, arg1: T1, arg2: T2, createAssertions: IAssertionPlant<TReturnValue>.() -> Unit): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which lazily evaluates IAssertions using the value returned by calling method of the subject with arg1 and arg2.

fun <T : Any, T1, T2, T3, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction3<T1, T2, T3, TReturnValue>, arg1: T1, arg2: T2, arg3: T3): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which immediately evaluates IAssertions using the value returned by calling method of the subject with arg1, arg2 and arg3.

fun <T : Any, T1, T2, T3, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction3<T1, T2, T3, TReturnValue>, arg1: T1, arg2: T2, arg3: T3, createAssertions: IAssertionPlant<TReturnValue>.() -> Unit): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which lazily evaluates IAssertions using the value returned by calling method of the subject with arg1, arg2 and arg3.

fun <T : Any, T1, T2, T3, T4, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction4<T1, T2, T3, T4, TReturnValue>, arg1: T1, arg2: T2, arg3: T3, arg4: T4): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which immediately evaluates IAssertions using the value returned by calling method of the subject with arg1, arg2, arg3 and arg4.

fun <T : Any, T1, T2, T3, T4, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction4<T1, T2, T3, T4, TReturnValue>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, createAssertions: IAssertionPlant<TReturnValue>.() -> Unit): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which lazily evaluates IAssertions using the value returned by calling method of the subject with arg1, arg2, arg3 and arg4.

fun <T : Any, T1, T2, T3, T4, T5, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction5<T1, T2, T3, T4, T5, TReturnValue>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which immediately evaluates IAssertions using the value returned by calling method of the subject with arg1, arg2, arg3, arg4 and arg5.

fun <T : Any, T1, T2, T3, T4, T5, TReturnValue : Any> IAssertionPlant<T>.returnValueOf(method: KFunction5<T1, T2, T3, T4, T5, TReturnValue>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, createAssertions: IAssertionPlant<TReturnValue>.() -> Unit): IAssertionPlant<TReturnValue>

Creates an IAssertionPlant which lazily evaluates IAssertions using the value returned by calling method of the subject with arg1, arg2, arg3, arg4 and arg5.

startsNotWith

fun <T : CharSequence> IAssertionPlant<T>.startsNotWith(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not start with expected.

startsWith

fun <T : CharSequence> IAssertionPlant<T>.startsWith(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject starts with expected.

toBe

fun <T : Any> IAssertionPlant<T>.toBe(expected: T): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is (equals) expected.