Пример #1
0
 @Test
 public void testIsCardPlayable() {
   Card card = cards.get(0);
   Ansage ansage = new Ansage(SpielModi.OBENABE);
   match.setAnsage(ansage);
   match.isCardPlayable(card);
   verify(jassRulesMock)
       .isCardPlayable(card, cards.subList(0, 9), new ArrayList<Card>(), ansage, true);
 }
Пример #2
0
 @Test
 public void testSchiebeAfterAnsage() {
   match.setAnsage(new Ansage(CardSuit.CLUBS));
   try {
     match.schiebe();
     fail();
   } catch (IllegalStateException e) {
     assertEquals("Ansage already set", e.getMessage());
   }
 }
Пример #3
0
 @Test
 public void testPlayCard() {
   Card card = cards.get(0);
   Ansage ansage = new Ansage(SpielModi.OBENABE);
   match.setAnsage(ansage);
   when(jassRulesMock.isCardPlayable(
           card, cards.subList(0, 9), new ArrayList<Card>(), ansage, true))
       .thenReturn(true);
   match.playCard(card);
 }
 @Before
 public void setup() {
   thirdPlayerStrategy = new ThirdPlayerStrategy();
   cardsInHand = new ArrayList<Card>();
   cardsOnTable = new ArrayList<PlayedCard>();
   match = mock(MatchImpl.class);
   when(match.isCardPlayable(any(Card.class))).thenReturn(true);
   when(match.getCardsOnTable()).thenReturn(cardsOnTable);
   when(match.getCards(any(PlayerToken.class))).thenReturn(cardsInHand);
   when(match.getAnsage()).thenReturn(new Ansage(CardSuit.HEARTS));
 }
Пример #5
0
  @Test
  public void testGetCardsOnTable() {
    Card card = cards.get(0);
    Ansage ansage = new Ansage(SpielModi.OBENABE);
    match.setAnsage(ansage);
    when(jassRulesMock.isCardPlayable(
            card, cards.subList(0, 9), new ArrayList<Card>(), ansage, true))
        .thenReturn(true);
    match.playCard(card);

    List<Card> cardsOnTable = match.getCardsOnTable();
    assertEquals(1, cardsOnTable.size());
    Card playedCard = cardsOnTable.get(0);
    assertEquals(card, playedCard);
    assertEquals(playerList.get(0), playedCard.getPlayer());
  }
Пример #6
0
  @Test
  public void testGetActivePlayer() {
    Card card = cards.get(0);
    Ansage ansage = new Ansage(SpielModi.OBENABE);
    match.setAnsage(ansage);
    when(jassRulesMock.isCardPlayable(
            any(Card.class),
            anyListOf(Card.class),
            anyListOf(Card.class),
            eq(ansage),
            anyBoolean()))
        .thenReturn(true);

    assertEquals(playerList.get(0), match.getActivePlayer());
    match.playCard(card);
    assertEquals(playerList.get(1), match.getActivePlayer());
  }
Пример #7
0
  @Test
  public void testIsComplete() {
    Ansage ansage = new Ansage(SpielModi.OBENABE);
    Card winnerCard = mock(Card.class);
    when(winnerCard.getPlayer()).thenReturn(PlayerToken.PLAYER0);
    match.setAnsage(ansage);
    when(jassRulesMock.isCardPlayable(
            any(Card.class),
            anyListOf(Card.class),
            anyListOf(Card.class),
            eq(new Ansage(SpielModi.OBENABE)),
            anyBoolean()))
        .thenReturn(true);
    when(scoreUtilMock.getWinnerCard(anyListOf(Card.class), eq(ansage))).thenReturn(winnerCard);

    assertFalse(match.isComplete());

    for (int i = 0; i < 36; i++) {
      if (i % 4 == 0 && i != 0) {
        match.collectCards();
      }
      match.playCard(match.getCards(match.getActivePlayer()).get(0));
    }
    assertTrue(match.isComplete());
  }
Пример #8
0
 @Test(expected = IllegalArgumentException.class)
 public void testPlayCardNotPlayable() {
   when(jassRulesMock.isCardPlayable(
           any(Card.class),
           anyListOf(Card.class),
           anyListOf(Card.class),
           any(Ansage.class),
           anyBoolean()))
       .thenReturn(false);
   match.playCard(cards.get(0));
 }
Пример #9
0
 @Test
 public void schiebe() {
   assertEquals(PlayerToken.PLAYER0, match.getActivePlayer());
   match.schiebe();
   assertTrue(match.isGeschoben());
   assertEquals(PlayerToken.PLAYER2, match.getActivePlayer());
   match.setAnsage(new Ansage(CardSuit.HEARTS));
   assertEquals(PlayerToken.PLAYER0, match.getActivePlayer());
 }
Пример #10
0
 @Test
 public void testGetCardsFromPlayer1() {
   List<Card> cardsPlayer0 = match.getCards(playerList.get(1));
   assertEquals(9, cardsPlayer0.size());
   assertEquals(cards.subList(9, 18), cardsPlayer0);
 }
Пример #11
0
 @Test(expected = IllegalArgumentException.class)
 public void testPlayCardWithNull() {
   match.playCard(null);
 }
Пример #12
0
 @Test(expected = IllegalArgumentException.class)
 public void setAnsageTwice() {
   Ansage ansage = new Ansage(SpielModi.OBENABE);
   match.setAnsage(ansage);
   match.setAnsage(ansage);
 }
Пример #13
0
 @Test
 public void setAndGetAnsage() {
   Ansage ansage = new Ansage(SpielModi.OBENABE);
   match.setAnsage(ansage);
   assertSame(ansage, match.getAnsage());
 }
Пример #14
0
 @Test
 public void getScore() {
   match.getScore();
   verify(scoreUtilMock).calculateScore(eq(match), any(WysStore.class));
 }