Add more tests
This commit is contained in:
parent
deafe5770e
commit
e0f107ccb4
1 changed files with 22 additions and 8 deletions
|
@ -20,7 +20,7 @@ class GameControllerTest {
|
|||
private fun GameController.at(id: Int): Area = field.first { it.id == id }
|
||||
|
||||
@Test
|
||||
fun testLevelEmptyBuilding() {
|
||||
fun aLevelMustBeInitiallyEmpty() {
|
||||
gameControllerOf(3, 3, 1).run {
|
||||
assertEquals(
|
||||
field.toList(),
|
||||
|
@ -36,17 +36,23 @@ class GameControllerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun testDismissFlagAfterOpen() {
|
||||
fun testGetTile() {
|
||||
gameControllerOf(3, 3, 1).run {
|
||||
assertEquals(getArea(4), field.first { it.id == 4 })
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun afterOpenATileItsMaskMustBeRemoved() {
|
||||
val mineCount = 3
|
||||
gameControllerOf(3, 3, mineCount).run {
|
||||
plantMinesExcept(3)
|
||||
at(3).mark = Mark.Flag
|
||||
singleClick(3)
|
||||
field.filter { it.isCovered }.forEach { it.mark = Mark.Flag }
|
||||
field.filterNot { it.hasMine }.map { it.id }.forEach { singleClick(it) }
|
||||
assertEquals(
|
||||
field.filter { it.isCovered }.count { it.mark.isFlag() },
|
||||
mineCount
|
||||
)
|
||||
assertFalse(at(3).mark.isFlag())
|
||||
singleClick(3)
|
||||
assertTrue(at(3).mark.isNone())
|
||||
assertFalse(at(3).isCovered)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,6 +73,14 @@ class GameControllerTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetMinesCount() {
|
||||
gameControllerOf(6, 6, 15, 200L).run {
|
||||
plantMinesExcept(3)
|
||||
assertEquals(15, getMinesCount())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlantMinesWithSafeArea() {
|
||||
gameControllerOf(9, 9, 12, 200L).run {
|
||||
|
|
Loading…
Reference in a new issue