givenEvent

open override fun givenEvent(event: Any, block: WhenDsl<S>.() -> Unit)

Sets up the aggregate with a single initial event.

This method initializes the aggregate state by replaying the specified domain event, simulating that the event has already occurred in the aggregate's history. This is useful for testing scenarios that depend on previous aggregate state changes.

Parameters

event

the initial domain event to replay on the aggregate

block

the test scenario continuation using WhenDsl for command execution


open override fun givenEvent(events: Array<out Any>, block: WhenDsl<S>.() -> Unit)

Sets up the aggregate by replaying multiple domain events.

This method initializes the aggregate state by replaying a sequence of domain events in order, reconstructing the aggregate's state as if these events had occurred previously. This enables testing of complex scenarios that require specific historical context.

Parameters

events

array of domain events to replay in sequence (empty array for no initial events)

block

the test scenario continuation using WhenDsl for command execution