Package test.util.proc

Source Code of test.util.proc.PassProcTest

package test.util.proc;
import net.sf.nebulacards.comm.*;
import net.sf.nebulacards.game.*;
import net.sf.nebulacards.main.*;
import net.sf.nebulacards.util.*;
import net.sf.nebulacards.util.proc.*;
import junit.framework.*;
import OneProcGame;
import Utility;

/**
* Test the PassProc class.  This test does not guarantee the
* correct functioning of a subclass of PassProc.  It only attempts
* to ensure that PassProc obeys its contract of when each of its
* methods is called.
* <p>This test is incomplete.  It only tests success scenarios.
* @author James Ranson
*/
public class PassProcTest
  extends TestCase
{
  final int NUM_PLAYERS = 3;
  OneProcGame opg;

  public PassProcTest(String s) { super(s); }

  class MyPassProc extends PassProc
  {
    public MyPassProc(CardGame g) { super(g); }
    protected int numPass(int p) { return p; }
    protected int wherePass(int p) { return p + 1; }
    protected boolean checkPass(int p, PileOfCards pass)
    {
      return true;
    }
  }

  class MyPlayer extends UIAdapter
  {
    PileOfCards hand;
    public void dealHand(PileOfCards h) { hand = h; }
    public void yourTurnToPass(int howmany, int who)
    {
      PileOfCards pass = new PileOfCards(howmany);
      for (int i = 0; i < howmany; i++)
        pass.add(hand.get(i));
      submitPass(pass);
    }
  }

  public void setUp()
  {
    opg = new OneProcGame("PassProc Test", NUM_PLAYERS);
    opg.setProc(new MyPassProc(opg));
    ComManager.AddResult cmar;
    MyPlayer mp;
    while ((cmar = opg.add(mp = new MyPlayer())) != null)
    {
      for (int i = 0; i < 10; i++)
        opg.getHands()[cmar.getPosition()].add(
                new PlayingCard(i, cmar.getPosition()));
      cmar.getCommunicator().dealHand(opg.getHands()[cmar.getPosition()]);
      cmar.publicize();
    }
  }

  public void testRun()
      throws InterruptedException
  {
    GameProcedure gp = opg.getNextProcedure();
    gp.runProcedure(Utility.getComs(opg), opg.getBroadcastCommunicator());
  }
}
TOP

Related Classes of test.util.proc.PassProcTest

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.