/*
 * Created on Nov 22, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package WheelOfFortune.game.wheel;

import junit.framework.TestCase;

/**
 * @author warren
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class WheelTest extends TestCase {
	
	public void testGetSpaceAt() throws Exception 
	{
		Wheel w = new Wheel("WheelOfFortune\\game\\wheel.txt");
		Space s = w.getSpaceAt(0);
		assertEquals(s.getAmount(), 200);
		assertEquals(s.getCode(), Space.NORMAL_SPACE);
		s= w.getSpaceAt(1);
		assertEquals(s.getAmount(), 500);
		assertEquals(s.getCode(), Space.NORMAL_SPACE);
		s = w.getSpaceAt(-1);
		assertEquals(s,null);
		s = w.getSpaceAt(2);
		assertEquals(s,null);
	}
	public void testSpin() throws Exception
	{
		Wheel w = new Wheel("WheelOfFortune\\game\\wheel.txt");
		for(int i = 0; i < 1000000; i++)
		{
			Space s = w.spin();
			assertNotNull(s);
		}
	}
	public void testGetNumSpaces() throws Exception
	{
		Wheel w1 = new Wheel("WheelOfFortune\\game\\wheel.txt");
		Wheel w2 = new Wheel("WheelOfFortune\\game\\wheel2.txt");
		assertEquals(w1.getNumSpaces(),2);
		assertEquals(w2.getNumSpaces(),20);
	}
	public void testGetCurrentIndex() throws Exception
	{
		Wheel w1 = new Wheel("WheelOfFortune\\game\\wheel2.txt");
		int ind = w1.getCurrentIndex();
		boolean lessThan20, grThanEq0;
		for(int i = 0; i < 5; i++)
		{	
			lessThan20 = ind < 20;
			grThanEq0 = ind >= 0;
			assertTrue(lessThan20);
			assertTrue(grThanEq0);
			w1.spin();
			if(w1.getCurrentIndex() != ind)
				System.out.println("Index Changed");
		}
	}
}
