package org.scotlandyard.tests.engine;
import java.util.logging.Level;
import java.util.logging.Logger;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.scotlandyard.engine.Token;
import org.scotlandyard.engine.constants.TransportationMethod;
import org.scotlandyard.engine.player.Player;
import org.scotlandyard.impl.engine.GameEngine;
import org.scotlandyard.impl.engine.TokenImpl;
/**
* TODO add description
*
* @author Hussain Al-Mutawa
* @version 1.0
* @since Sept 2011
*
*/
public class TokenTest {
private transient Player player;
private transient TransportationMethod transportation;
private transient Token token;
@BeforeClass //TODO add description here
public static void beforeClass()throws Exception{
GameEngine.instance().clearRecords();
}
@Before //TODO add description here
public void setUp()throws Exception{
token = new TokenImpl(player, transportation);
}
@Test //TODO add description here
public final void testTokenImpl() {
final Token temp =new TokenImpl(player,transportation);
Assert.assertEquals(token.getNumberOfTokens(), temp.getNumberOfTokens());
}
@Test //TODO add description here
public final void testGetNumberOfTokens() {
final int tickets = token.getNumberOfTokens();
Assert.assertEquals(tickets, 0);
}
@Test //TODO add description here
public final void testGetTransportationMethod() {
Assert.assertEquals(transportation, token.getTransportationMethod());
}
@Test //TODO add description here
public final void testAddTicket() {
token.addTicket();
token.addTicket();
Assert.assertEquals(token.getNumberOfTokens(), 2);
}
@Test //TODO add description here
public final void testConsumeTicket() {
try {
Assert.assertTrue(
"check if the number of tickets is more than zero",
token.getNumberOfTokens()>0
);
token.consumeTicket();
Assert.assertEquals(token.getNumberOfTokens(), 1);
} catch (Exception ex) {
Logger.getLogger(TokenTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Test //TODO add description here
public final void testGetPlayer() {
Assert.assertEquals(player, token.getPlayer());
}
}