-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(game): add move down next check
- Loading branch information
1 parent
48dea91
commit a1244be
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ package movements | |
enum class Direction { | ||
LEFT, | ||
RIGHT, | ||
DOWN | ||
DOWN, | ||
UP | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package game | ||
|
||
import block_factory.BlockCreator | ||
import blocks.implementation.IBlock | ||
import movements.Direction | ||
import movements.Position | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import score.Points | ||
import score.ScoreCalculator | ||
import kotlin.test.assertTrue | ||
|
||
class GameMoveDownNextTest { | ||
|
||
private lateinit var game: Game | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
game = Game(object : BlockCreator { | ||
override fun getBlock() = IBlock(Position(0, (GAME_COLUMNS / 2) - 2)) | ||
}, object : ScoreCalculator { | ||
override fun getScore(cleanedRows: Int) = Points(0) | ||
}) | ||
game.getNextBlock() | ||
} | ||
|
||
@Test | ||
fun `first move always can move down`() { | ||
assertTrue(game.blockCanMoveDownNext()) | ||
} | ||
|
||
@Test | ||
fun `down the board less 1 can move down`() { | ||
for (i in 1 until GAME_ROWS - 2) | ||
game.moveBlock(Direction.DOWN) | ||
assertTrue(game.blockCanMoveDownNext()) | ||
} | ||
|
||
@Test | ||
fun `down the board can't move more`() { | ||
for (i in 1 until GAME_ROWS - 1) | ||
game.moveBlock(Direction.DOWN) | ||
assertFalse(game.blockCanMoveDownNext()) | ||
} | ||
|
||
} |