package ch.dissem.yaep.domain

import ch.tutteli.atrium.api.fluent.en_GB.toEqual
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test

class OrderClueTest : ClueTest() {
    @Test
    fun `ensure items in correct order are valid`() {
        val grid = createGrid()
        for (ia in 0 until size) {
            for (ib in 0 until size) {
                for (ic in 0 until size) {
                    for (ja in 0 until size - 1) {
                        for (jb in ja + 1 until size) {
                            val a = grid[ia][ja]
                            val b = grid[ib][jb]

                            expect(OrderClue(a.solution!!, b.solution!!).isValid(grid)).toEqual(true)
                        }
                    }
                }
            }
        }
    }

    @Test
    fun `ensure items in wrong order are valid`() {
        val grid = createGrid()
        for (ia in 0 until size) {
            for (ib in 0 until size) {
                for (ic in 0 until size) {
                    for (ja in 0 until size - 1) {
                        for (jb in ja until size) {
                            val a = grid[ia][ja]
                            val b = grid[ib][jb]

                            expect(OrderClue(b.solution!!, a.solution!!).isValid(grid)).toEqual(false)
                        }
                    }
                }
            }
        }
    }

    @Test
    fun `ensure items in the same column are not valid`() {
        val grid = createGrid()
        for (rowA in grid.rows) {
            for (rowB in grid.rows) {
                for (i in 0 until size) {
                    expect(OrderClue(rowA[i].solution!!, rowB[i].solution!!).isValid(grid)).toEqual(false)
                }
            }
        }
    }
}
