From c0036da04379022ce681356328c54f6bffb497f3 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Wed, 25 Apr 2018 22:36:45 +0200 Subject: Add WonderTest --- .../sevenwonders/game/wonders/WonderTest.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java (limited to 'game-engine/src/test/java') diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java new file mode 100644 index 00000000..5bf2affa --- /dev/null +++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java @@ -0,0 +1,37 @@ +package org.luxons.sevenwonders.game.wonders; + +import org.junit.Test; +import org.luxons.sevenwonders.game.cards.CardBack; +import org.luxons.sevenwonders.game.test.TestUtils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class WonderTest { + + @Test + public void buildLevel_increasesNbBuiltStages() { + Wonder wonder = TestUtils.createWonder(); + assertEquals(0, wonder.getNbBuiltStages()); + wonder.buildLevel(new CardBack("img")); + assertEquals(1, wonder.getNbBuiltStages()); + wonder.buildLevel(new CardBack("img")); + assertEquals(2, wonder.getNbBuiltStages()); + wonder.buildLevel(new CardBack("img")); + assertEquals(3, wonder.getNbBuiltStages()); + } + + @Test + public void buildLevel_failsIfFull() { + Wonder wonder = TestUtils.createWonder(); + wonder.buildLevel(new CardBack("img")); + wonder.buildLevel(new CardBack("img")); + wonder.buildLevel(new CardBack("img")); + try { + wonder.buildLevel(new CardBack("img")); + fail(); + } catch (IllegalStateException e) { + // expected exception because there is no 4th level in this wonder + } + } +} -- cgit