func (sc ProcessManagerThen) Using(t *testing.T, processManagerFactory ProcessManagerFactory) {
	ctx := context.Background()
	commandDispatcher := command.NewTrackingDispatcher()
	processManager := processManagerFactory(commandDispatcher)
	for _, event := range sc.given {
		if err := processManager.Apply(ctx, event); !assert.NoError(t, err) {
			return
		}
	}
	commandDispatcher.FlushCommands()
	err := processManager.Apply(ctx, sc.when)
	if !sc.wantError {
		assert.NoError(t, err)
		assert.Equal(t, sc.then, commandDispatcher.RecordedCommands())
		return
	}
	if !assert.Error(t, err) {
		return
	}
	if sc.thenError != nil {
		assert.ErrorIs(t, err, sc.thenError)
	}
}
Using performs the specified expectations of the scenario,
using the Process Manager instance produced by the provided factory function.
package scenario
import (
	"context"
	"testing"
	"github.com/stretchr/testify/assert"
	"github.com/get-eventually/go-eventually"
	"github.com/get-eventually/go-eventually/command"
	"github.com/get-eventually/go-eventually/eventstore"
	"github.com/get-eventually/go-eventually/projection"
)
type ProcessManagerInit struct{}
func ProcessManager() ProcessManagerInit {
	return ProcessManagerInit{}
}
func (ProcessManagerInit) Given(events ...eventstore.Event) ProcessManagerGiven {
	return ProcessManagerGiven{
		given: events,
	}
}
type ProcessManagerGiven struct {
	given []eventstore.Event
}
func (sc ProcessManagerGiven) When(event eventstore.Event) *ProcessManagerWhen {
	return &ProcessManagerWhen{
		ProcessManagerGiven: sc,
		when:                event,
	}
}
type ProcessManagerWhen struct {
	ProcessManagerGiven
	when eventstore.Event
}
func (sc *ProcessManagerWhen) Then(commands ...eventually.Command) ProcessManagerThen {
	return ProcessManagerThen{
		ProcessManagerWhen: sc,
		then:               commands,
	}
}
func (sc *ProcessManagerWhen) ThenError(err error) ProcessManagerThen {
	return ProcessManagerThen{
		ProcessManagerWhen: sc,
		thenError:          err,
		wantError:          true,
	}
}
func (sc *ProcessManagerWhen) ThenFails() ProcessManagerThen {
	return ProcessManagerThen{
		ProcessManagerWhen: sc,
		wantError:          true,
	}
}
type ProcessManagerThen struct {
	*ProcessManagerWhen
	then      []eventually.Command
	thenError error
	wantError bool
}
type ProcessManagerFactory func(cd command.Dispatcher) projection.Applier