Skip to content

Commit

Permalink
chore: refactored test structure
Browse files Browse the repository at this point in the history
  • Loading branch information
alemazzo committed Sep 20, 2023
1 parent e278457 commit c5484d8
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions src/test/scala/scatan/model/TurnTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,43 @@ import scatan.BaseTest

class TurnTest extends BaseTest:

"A turn" should "have a number" in {
val turn = Turn(1, Player("a"))
turn.number shouldBe 1
}

it should "not allow to have a number less than 1" in {
assertThrows[IllegalArgumentException] {
Turn(0, Player("a"))
}
}

it should "have a player" in {
val turn = Turn(1, Player("a"))
turn.player shouldBe Player("a")
}

class NewGameTest extends BaseTest:

val players = Seq(Player("a"), Player("b"), Player("c"), Player("d"))

"A game" should "have a turn" in {
val game = Game(Seq(Player("a"), Player("b"), Player("c"), Player("d")))
game.currentTurn shouldBe Turn(1, Player("a"))
val game = Game(players)
game.currentTurn shouldBe Turn(1, players(0))
}

it should "have a next turn" in {
val game = Game(Seq(Player("a"), Player("b"), Player("c"), Player("d")))
game.nextTurn.currentTurn shouldBe Turn(2, Player("b"))
val game = Game(players)
game.nextTurn.currentTurn shouldBe Turn(2, players(1))
}

it should "do a circular turn" in {
val gameWith4Players = Game(Seq(Player("a"), Player("b"), Player("c"), Player("d")))
val gameWith4Players = Game(players)
val playersTurnIterator = Iterator.iterate(gameWith4Players)(_.nextTurn).map(_.currentPlayer)
val playersIterator = Iterator.continually(Seq(Player("a"), Player("b"), Player("c"), Player("d"))).flatten
val playersIterator = Iterator.continually(players).flatten
playersTurnIterator.take(100).toList shouldBe playersIterator.take(100).toList
}

"A turn" should "have a number" in {
val turn = Turn(1, Player("a"))
turn.number shouldBe 1
}

it should "have a player" in {
val turn = Turn(1, Player("a"))
turn.player shouldBe Player("a")
}

/*
it should "have a phase" in {
val turn = Turn(1, Player("a"))
Expand Down

0 comments on commit c5484d8

Please sign in to comment.