Browse Source

Test.playCard

main
fdai7920 12 months ago
parent
commit
4a80d5d3e9
  1. 5
      src/main/java/de/hsfulda/onses/services/GameService.java
  2. 38
      src/test/java/de/hsfulda/onses/GameServiceTest.java

5
src/main/java/de/hsfulda/onses/services/GameService.java

@ -13,6 +13,10 @@ public class GameService {
this(new Game());
}
public Game getGame() {
return game;
}
public void playCard(Player player, Card card)
{
// add lastPlayedCard back to drawCardDeck
@ -20,4 +24,5 @@ public class GameService {
// check for special rules (draw, colorchoose, skip,...)
}
}

38
src/test/java/de/hsfulda/onses/GameServiceTest.java

@ -0,0 +1,38 @@
package de.hsfulda.onses;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import de.hsfulda.onses.models.Card;
import de.hsfulda.onses.models.Player;
import de.hsfulda.onses.models.Game;
import de.hsfulda.onses.services.GameService;
public class GameServiceTest {
@Test
@DisplayName("playCardRedEight")
public void playCardRedEight() {
// arrange
Card input = new Card().setColor(Card.Color.RED).setValue(Card.Value.EIGHT);
// act
GameService gameService = new GameService();
gameService.playCard(new Player(), input);
Card answer = gameService.getGame().getLastPlayedCard();
// assert
assertEquals(input, answer);
}
@Test
@DisplayName("playCardBlackChoose")
public void playCardBlackChoose() {
// arrange
Card input = new Card().setColor(Card.Color.BLACK).setValue(Card.Value.CHOOSE);
// act
GameService gameService = new GameService();
gameService.playCard(new Player(), input);
Card answer = gameService.getGame().getLastPlayedCard();
// assert
assertEquals(input, answer);
}
}
Loading…
Cancel
Save