package com.correx.infrastructure.persistence

import com.correx.core.events.stores.EventStore
import com.correx.core.sessions.SessionCounterProjection
import com.correx.core.sessions.SessionCounterState
import com.correx.core.sessions.projections.replay.DefaultEventReplayer
import com.correx.core.sessions.projections.replay.EventReplayer
import com.correx.testing.contracts.fixtures.artifactstore.NoopArtifactStore
import com.correx.testing.contracts.fixtures.projections.SessionReplayContractTest
import java.sql.DriverManager

class SqliteReplayTest : SessionReplayContractTest() {

    override fun store(): EventStore {
        val connection =
            DriverManager.getConnection("jdbc:sqlite::memory:")

        return SqliteEventStore(connection, artifactStore = NoopArtifactStore())
    }

    override fun replayer(
        store: EventStore
    ): EventReplayer<SessionCounterState> {
        return DefaultEventReplayer(
            store,
            SessionCounterProjection("s1")
        )
    }
}
