package domain

import androidx.compose.runtime.TestOnly
import ch.tutteli.atrium.api.fluent.en_GB.extractSubject
import ch.tutteli.atrium.api.fluent.en_GB.feature
import ch.tutteli.atrium.api.fluent.en_GB.size
import ch.tutteli.atrium.api.fluent.en_GB.toBeLessThan
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
import ch.tutteli.atrium.api.fluent.en_GB.toHaveElementsAndAll
import ch.tutteli.atrium.api.fluent.en_GB.toHaveElementsAndNone
import ch.tutteli.atrium.api.fluent.en_GB.toHaveSize
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test

class GameTest {

//    @Test
//    fun `try to find the error`() {
//        val size = 6
//        val classes = ItemClass.randomClasses(size)
//
//        val grid: List<List<Item<ItemClass<*>>>> = classes.map {
//            it.randomItems(size).map { item -> Item(item) }
//        }
//
//        // Build a set C of all possible clues that pertain to this puzzle instance.
//        // (There are a finite and in fact quite small number of possible clues: for example
//        // if there are 5 houses, there are 5 possible clues of the form "Person A lives in
//        // house B", 8 possible clues of the form "Person A lives next to house B", and so on.)
//        val clues = getAllClues(grid).shuffled()
//
//        val gameGrid = grid.toGrid()
//        gameGrid.flatMap { it }.forEach { it.selection = it.solution }
//
//        expect(clues).toHaveElementsAndAll {
//            feature { f(it::isRuleViolated, gameGrid) }.toEqual(false)
//        }
//    }
    @Test
    fun `ensure generated game is valid`() {
        val game = generateGame()
        expect(game) {
            feature(Game::areCategoriesValid).toEqual(true)
            feature(Game::areRulesViolated).toEqual(false)
            feature(Game::clues) {
                feature(List<Clue>::size).toBeLessThan(30)
            }
        }
    }

}