TWiki home XP > XP > TestaBaralhoIteracaoFinal ( vs. r1.1) XP webs:
Main | TWiki | Sandbox | Portugues
XP . { Bugzilla Últimas atualizações Busca Registro Sobre o TWiki }
 <<O>>  Difference Topic TestaBaralhoIteracaoFinal (r1.1 - 07 Jul 2005 - AndreGermanoRegert)
Line: 1 to 1
Added:
>
>
META TOPICPARENT TestesParaOJogoDoMeio
-- AndreGermanoRegert - 07 Jul 2005


/*
 * Criado em 02/07/2005
 */
package testesDoJogoDoMeio;

import jogoDoMeio.Baralho;
import junit.framework.Assert;
/**
 * @author André Germano Regert
 *          Jader Wallauer
 */

public class testaBaralho {

   public static void main(String[] args) {
      
      TestaNumeroDeNaipes();
      TestaNumeroDeCartas();
      TestaMonteEstaCompleto();
      TestaEmbaralha();
      TestaTiraCarta();
      TestaQualEACarta();
      TestaValorDeCartas();
      testaValorInteiroDeCarta();
                  
      System.out.println("Baralho OK");
   }
   
   public static void TestaMonteEstaCompleto(){
      Baralho b = new Baralho(4,52);
      assert b.MonteEstaCompleto() : "O baralho não está completo";
   }
   
   public static void TestaEmbaralha(){
      Baralho b = new Baralho(4,52);
      b.Embaralha();
      assert b.EstaEmbaralhado() : "O Baralho não foi embaralhado";
   }
   
   public static void TestaTiraCarta(){
      Baralho b = new Baralho(4,52);
      int carta = b.TiraCarta();
      assert (1 <= carta) && (52 >= carta): "Não foi retirada uma carta";
   }
   
   public static void TestaQualEACarta(){
      Baralho b = new Baralho(4,52);
      b.Embaralha();
      int carta = b.TiraCarta();
      String nomeDaCarta = b.QualEACarta(carta);
      Assert.assertFalse("A carta não foi identificada",nomeDaCarta.equals(""));
   }
   
   public static void TestaNumeroDeNaipes(){
      try {
         Baralho b = new Baralho(3,52);
        } catch (AssertionError ae) {
           assert ae.getMessage().equals("O baralho precisa ter 4 naipes");
            //if (ae.getMessage().equals("O baralho precisa ter 4 naipes")) {
            //throw ae; 
         //}
        }  
   }

   public static void TestaNumeroDeCartas(){
      try {
         Baralho b = new Baralho(4,53);
        } catch (AssertionError ae) {
           assert ae.getMessage().equals("O baralho precisa ter 52 cartas");
            //if (ae.getMessage().equals("O baralho precisa ter 52 cartas")) {
            //throw ae; 
         //}
        }  
   }

   public static void TestaValorDeCartas(){
      try {
         Baralho b = new Baralho(4,52);
         b.QualEACarta(53);
        } catch (AssertionError ae) {
           assert ae.getMessage().equals("Esta carta não existe");
            //if (ae.getMessage().equals("Esta carta não existe")) {
            //throw ae; 
         //}
        }  
   }

   private static void testaValorInteiroDeCarta() {
      Baralho b = new Baralho(4,52);
      int carta = b.TiraCarta();
      int valor = b.valorInteiro(carta);
      assert ((valor >= 1) && (valor <= 13)):"Não foi retornado um valor inteiro válido para a carta";
   }
}


Topic TestaBaralhoIteracaoFinal . { View | Diffs | r1.1 | More }
Revision -
Revision r1.1 - 07 Jul 2005 - 22:47 - AndreGermanoRegert
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding XP? Send feedback.