withCanvasSource

fun <T : Any, V : T> withCanvasSource(clazz: KClass<T>, obj: V): TestMosaicBuilder(source)

Borrows a caller-owned source for the canvas with the specified class and object. Allows for passing in a superclass as the retrieval type.

Return

This builder for method chaining

mosaicBuilder()
.withCanvasSource(User::class, User("test-user"))
.withMockTile(MyTile, "test data")
.withMosaic { /* compose and assert here */}

Parameters

clazz

The class of the object to register

obj

The object to register


Borrows a caller-owned source for the canvas with the specified object.

Return

This builder for method chaining

mosaicBuilder()
.withCanvasSource(User("test-user"))
.withMockTile(MyTile, "test data")
.withMosaic { /* compose and assert here */}

Parameters

obj

The object to register


fun <T : Any, V : T> withCanvasSource(clazz: KClass<T>, qualifier: String, obj: V): TestMosaicBuilder(source)

Borrows a caller-owned source for the canvas with the specified class, qualifier, and object.

Return

This builder for method chaining

mosaicBuilder()
.withCanvasSource(DatabaseService::class, "primary", primaryDb)
.withCanvasSource(DatabaseService::class, "secondary", secondaryDb)
.withMosaic { /* compose and assert here */}

Parameters

clazz

The class of the object to register

qualifier

The qualifier to distinguish this instance

obj

The object to register


inline fun <T : Any> withCanvasSource(qualifier: String, obj: T): TestMosaicBuilder(source)

Borrows a caller-owned source for the canvas with the specified object and qualifier.

Return

This builder for method chaining

mosaicBuilder()
.withCanvasSource("primary", primaryDb)
.withCanvasSource("secondary", secondaryDb)
.withMosaic { /* compose and assert here */}

Parameters

qualifier

The qualifier to distinguish this instance

obj

The object to register


Borrows a caller-owned source for the canvas using a CanvasKey.

Return

This builder for method chaining

val dbKey = CanvasKey(DatabaseService::class, "primary")
mosaicBuilder()
.withCanvasSource(dbKey, primaryDb)
.withMosaic { /* compose and assert here */}

Parameters

key

The canvas key to register under

obj

The object to register