src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java
changeset 97 89f13f209302
parent 46 c592dd7b0595
     1.1 --- a/src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java	Sun Jun 19 15:11:22 2011 +0400
     1.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java	Sun Jun 19 17:53:59 2011 +0400
     1.3 @@ -1,19 +1,89 @@
     1.4  package ru.alphatech.icfpc.cards.tests;
     1.5  
     1.6 -import static org.junit.Assert.*;
     1.7 +import junit.framework.Assert;
     1.8  
     1.9  import org.junit.Test;
    1.10  
    1.11 +import ru.alphatech.icfpc.cards.Get;
    1.12 +import ru.alphatech.icfpc.cards.I;
    1.13 +import ru.alphatech.icfpc.game.ICFPCException;
    1.14 +import ru.alphatech.icfpc.game.IValue;
    1.15 +import ru.alphatech.icfpc.game.Player;
    1.16 +import ru.alphatech.icfpc.game.Value;
    1.17 +
    1.18  /**
    1.19 - * @author indvdum
    1.20 + * @author indvdum (idea)
    1.21 + * @author 0-range (implementation)
    1.22   * 18.06.2011 19:42:44
    1.23   *
    1.24   */
    1.25 -public class TestGet {
    1.26 +public class TestGet extends Assert
    1.27 +{
    1.28 +	@Test
    1.29 +	public final void testReturnValue()
    1.30 +	{
    1.31 +		Player opponent = new Player();
    1.32 +		Player proponent = new Player();
    1.33 +
    1.34 +		IValue i = new Value(0);
    1.35 +		IValue value = new Value(99);
    1.36 +
    1.37 +		proponent.getSlot(((Value)i).getValue()).putValue(value);
    1.38 +		assertEquals(value, new Get().returnValue(i, proponent, opponent));
    1.39 +	}
    1.40  
    1.41  	@Test
    1.42 -	public final void testReturnValue() {
    1.43 -		assertEquals("test", "test");
    1.44 +	public final void testNotSlotNumber()
    1.45 +	{
    1.46 +		Player opponent = new Player();
    1.47 +		Player proponent = new Player();
    1.48 +
    1.49 +		try
    1.50 +		{
    1.51 +			IValue i = new I();
    1.52 +			new Get().returnValue(i, proponent, opponent);
    1.53 +			assertTrue(false);
    1.54 +		}
    1.55 +		catch (ICFPCException e)
    1.56 +		{
    1.57 +			assertTrue(true);
    1.58 +		}
    1.59  	}
    1.60  
    1.61 +	@Test
    1.62 +	public final void testInvalidSlotNumber()
    1.63 +	{
    1.64 +		Player opponent = new Player();
    1.65 +		Player proponent = new Player();
    1.66 +
    1.67 +		try
    1.68 +		{
    1.69 +			IValue i = new Value(999);
    1.70 +			new Get().returnValue(i, proponent, opponent);
    1.71 +			assertTrue(false);
    1.72 +		}
    1.73 +		catch (ICFPCException e)
    1.74 +		{
    1.75 +			assertTrue(true);
    1.76 +		}
    1.77 +	}
    1.78 +
    1.79 +	@Test
    1.80 +	public final void testIfSlotDead()
    1.81 +	{
    1.82 +		Player opponent = new Player();
    1.83 +		Player proponent = new Player();
    1.84 +
    1.85 +		try
    1.86 +		{
    1.87 +			IValue i = new Value(0);
    1.88 +			proponent.getSlot(((Value)i).getValue()).setVitality(0);
    1.89 +			new Get().returnValue(i, proponent, opponent);
    1.90 +			assertTrue(false);
    1.91 +		}
    1.92 +		catch (ICFPCException e)
    1.93 +		{
    1.94 +			assertTrue(true);
    1.95 +		}
    1.96 +	}
    1.97  }