Browse Source

refactoring: rearrange code structure

main
fdai7906 11 months ago
parent
commit
ba1bb9b313
  1. 37
      src/test/java/de/hsfulda/onses/GameTest.java

37
src/test/java/de/hsfulda/onses/GameTest.java

@ -12,39 +12,46 @@ public class GameTest {
@Test @Test
@DisplayName("lastPlayedCard") @DisplayName("lastPlayedCard")
public void lastPlayedCard() { public void lastPlayedCard() {
// arrange
Game game = new Game(); Game game = new Game();
Card card = new Card().setColor(Card.Color.RED).setValue(Card.Value.EIGHT);
Card card = new Card();
// act
card.setColor(Card.Color.RED).setValue(Card.Value.EIGHT);
Card answer = card; Card answer = card;
game.setLastPlayedCard(card); game.setLastPlayedCard(card);
// assert
assertEquals(game.getLastPlayedCard(), answer); assertEquals(game.getLastPlayedCard(), answer);
} }
@Test @Test
@DisplayName("GetDrawCardDeck") @DisplayName("GetDrawCardDeck")
public void GetDrawCardDeck() { public void GetDrawCardDeck() {
// arrange
Game game = new Game(); Game game = new Game();
Card card = new Card().setColor(Card.Color.RED).setValue(Card.Value.EIGHT);
Card card = new Card();
// act
card.setColor(Card.Color.RED).setValue(Card.Value.EIGHT);
Card answer = card; Card answer = card;
game.addCardToDrawCardDeck(card); game.addCardToDrawCardDeck(card);
// assert
assertEquals(game.getDrawCardDeck().getFirst(), answer); assertEquals(game.getDrawCardDeck().getFirst(), answer);
} }
@Test @Test
@DisplayName("GetTwoCardsFromDrawCardDeck") @DisplayName("GetTwoCardsFromDrawCardDeck")
public void GetTwoCardsFromDrawCardDeck() { public void GetTwoCardsFromDrawCardDeck() {
// arrange
Game game = new Game(); Game game = new Game();
Card card1 = new Card().setColor(Card.Color.RED).setValue(Card.Value.EIGHT);
Card card2 = new Card().setColor(Card.Color.BLUE).setValue(Card.Value.ONE);
Card card1 = new Card();
Card card2 = new Card();
// act
card1.setColor(Card.Color.RED).setValue(Card.Value.EIGHT);
card2.setColor(Card.Color.BLUE).setValue(Card.Value.ONE);
Card answer1 = card1; Card answer1 = card1;
Card answer2 = card2; Card answer2 = card2;
game.addCardToDrawCardDeck(card1); game.addCardToDrawCardDeck(card1);
game.addCardToDrawCardDeck(card2); game.addCardToDrawCardDeck(card2);
// assert
assertEquals(game.getDrawCardDeck().getFirst(), answer1); assertEquals(game.getDrawCardDeck().getFirst(), answer1);
assertEquals(game.getDrawCardDeck().get(1), answer2); assertEquals(game.getDrawCardDeck().get(1), answer2);
} }
@ -63,10 +70,11 @@ public class GameTest {
@Test @Test
@DisplayName("CheckForGetGameOver") @DisplayName("CheckForGetGameOver")
public void CheckForGetGameOver() { public void CheckForGetGameOver() {
// arrange
GameService gameService = new GameService(); GameService gameService = new GameService();
// act
boolean gameOver = gameService.getGame().getGameOver(); boolean gameOver = gameService.getGame().getGameOver();
//assert
assertFalse(gameOver); assertFalse(gameOver);
} }
@ -74,11 +82,12 @@ public class GameTest {
@Test @Test
@DisplayName("CheckForSetGameOver") @DisplayName("CheckForSetGameOver")
public void CheckForSetGameOver() { public void CheckForSetGameOver() {
// arrange
GameService gameService = new GameService(); GameService gameService = new GameService();
// act
gameService.getGame().setGameOver(true); gameService.getGame().setGameOver(true);
boolean gameOver = gameService.getGame().getGameOver(); boolean gameOver = gameService.getGame().getGameOver();
// assert
assertTrue(gameOver); assertTrue(gameOver);
} }
} }
Loading…
Cancel
Save