Reorganize tests

This commit is contained in:
Claude Brisson
2023-12-23 07:18:53 +01:00
parent abd9fdf837
commit e666efdcc3
3 changed files with 168 additions and 146 deletions

View File

@@ -0,0 +1,23 @@
package org.jeudego.pairgoth.test
import com.republicate.kson.Json
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class MacMahonTest {
@Test
fun `Mac Mahon with handicap`() {
var resp = TestAPI.post("/api/tour", BasicTests.aMMTournament).asObject()
val tourId = resp.getInt("id") ?: throw Error("tournament creation failed")
resp = TestAPI.post("/api/tour/$tourId/part", BasicTests.aPlayer).asObject().also { assertTrue(it.getBoolean("success")!!) }
val p1 = resp.getInt("id")!!
resp = TestAPI.post("/api/tour/$tourId/part", BasicTests.anotherPlayer).asObject().also { assertTrue(it.getBoolean("success")!!) }
val p2 = resp.getInt("id")!!
val game = TestAPI.post("/api/tour/$tourId/pair/1", Json.Array("all")).asArray().getObject(0) ?: throw Error("pairing failed")
assertEquals(p2, game.getInt("w"))
assertEquals(p1, game.getInt("b"))
assertEquals(3, game.getInt("h"))
}
}