Package belotetime.tests

Source Code of belotetime.tests.TestPack

package belotetime.tests;

import static org.junit.Assert.*;

import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import belotetime.application.game.Card;
import belotetime.application.game.Pack;
import belotetime.application.game.Set;

public class TestPack
{
  private Pack packet;
 
  public TestPack()
  {
    ArrayList<Card> listCards = new ArrayList<>();
        listCards.add(new Card("Sept", "Coeur", 0));
        listCards.add(new Card("Huit", "Coeur", 0));
        listCards.add(new Card("Neuf", "Coeur", 0));
        listCards.add(new Card("Dix", "Coeur", 10));
        listCards.add(new Card("Valet", "Coeur", 2));
        listCards.add(new Card("Dame", "Coeur", 3));
        listCards.add(new Card("Roi", "Coeur", 4));
        listCards.add(new Card("As", "Coeur", 11));
        listCards.add(new Card("Sept", "Tr�fle", 0));
        listCards.add(new Card("Huit", "Tr�fle", 0));
        listCards.add(new Card("Neuf", "Tr�fle", 0));
        listCards.add(new Card("Dix", "Tr�fle", 10));
        listCards.add(new Card("Valet", "Tr�fle", 2));
        listCards.add(new Card("Dame", "Tr�fle", 3));
        listCards.add(new Card("Roi", "Tr�fle", 4));
        listCards.add(new Card("As", "Tr�fle", 11));
        listCards.add(new Card("Sept", "Carreau", 0));
        listCards.add(new Card("Huit", "Carreau", 0));
        listCards.add(new Card("Neuf", "Carreau", 0));
        listCards.add(new Card("Dix", "Carreau", 10));
        listCards.add(new Card("Valet", "Carreau", 2));
        listCards.add(new Card("Dame", "Carreau", 3));
        listCards.add(new Card("Roi", "Carreau", 4));
        listCards.add(new Card("As", "Carreau", 11));
        listCards.add(new Card("Sept", "Pique", 0));
        listCards.add(new Card("Huit", "Pique", 0));
        listCards.add(new Card("Neuf", "Pique", 0));
        listCards.add(new Card("Dix", "Pique", 10));
        listCards.add(new Card("Valet", "Pique", 2));
        listCards.add(new Card("Dame", "Pique", 3));
        listCards.add(new Card("Roi", "Pique", 4));
        listCards.add(new Card("As", "Pique", 11));
       
        packet = new Pack(listCards);
  }
 
  @Before
  public void beforeTest()
  {
    displayPack(packet);
  }
 
  @After
  public void afterTest()
  {
    displayPack(packet);
  }
 
  @Test
  public void testShuffle()
  {
    Pack p = new Pack(packet.getCards());
    packet.shuffle();
    assertTrue(packet.getCards().size() == 32);
    assertFalse(packet.getCards().equals(p.getCards()));
  }
 
  @Test
  public void testCut()
  {
    packet.cut();
    assertTrue(packet.getCards().size() == 32);
  }
 
  @Test
  public void testGetPoints()
  {
    assertTrue(packet.getPoints() == 120);
  }
 
  @Test
  public void testDeal()
  {
    Card c = packet.getCards().get(packet.getCards().size() - 1);
    Card c2 = packet.deal();
    assertTrue(c == c2);
    assertTrue(packet.getCards().size() == 31);
  }
 
  @Test
  public void testDealWithArg()
  {
    Pack p = new Pack();
   
    for(int i = 0; i < 3; i++)
    {
      p.getCards().add(packet.getCards().get(packet.getCards().size() - i - 1));
    }
   
    Pack p2 = packet.deal(Set.THREE_CARDS);
   
    for(int i = 0; i < 3; i++)
    {
      assertTrue(p2.getCards().get(i).equals(p.getCards().get(i)));
    }
   
    assertTrue(packet.getCards().size() == 29);
  }
 
  public void displayPack(Pack p)
  {
    for(Card c : p.getCards())
    {
      System.out.println(c);
    }
   
    System.out.println();
  }

}
TOP

Related Classes of belotetime.tests.TestPack

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.