src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java
author 0-range@bazon.ru
Sun, 19 Jun 2011 17:53:59 +0400
changeset 97 89f13f209302
parent 46 c592dd7b0595
permissions -rw-r--r--
changes
     1 package ru.alphatech.icfpc.cards.tests;
     2 
     3 import junit.framework.Assert;
     4 
     5 import org.junit.Test;
     6 
     7 import ru.alphatech.icfpc.cards.Get;
     8 import ru.alphatech.icfpc.cards.I;
     9 import ru.alphatech.icfpc.game.ICFPCException;
    10 import ru.alphatech.icfpc.game.IValue;
    11 import ru.alphatech.icfpc.game.Player;
    12 import ru.alphatech.icfpc.game.Value;
    13 
    14 /**
    15  * @author indvdum (idea)
    16  * @author 0-range (implementation)
    17  * 18.06.2011 19:42:44
    18  *
    19  */
    20 public class TestGet extends Assert
    21 {
    22 	@Test
    23 	public final void testReturnValue()
    24 	{
    25 		Player opponent = new Player();
    26 		Player proponent = new Player();
    27 
    28 		IValue i = new Value(0);
    29 		IValue value = new Value(99);
    30 
    31 		proponent.getSlot(((Value)i).getValue()).putValue(value);
    32 		assertEquals(value, new Get().returnValue(i, proponent, opponent));
    33 	}
    34 
    35 	@Test
    36 	public final void testNotSlotNumber()
    37 	{
    38 		Player opponent = new Player();
    39 		Player proponent = new Player();
    40 
    41 		try
    42 		{
    43 			IValue i = new I();
    44 			new Get().returnValue(i, proponent, opponent);
    45 			assertTrue(false);
    46 		}
    47 		catch (ICFPCException e)
    48 		{
    49 			assertTrue(true);
    50 		}
    51 	}
    52 
    53 	@Test
    54 	public final void testInvalidSlotNumber()
    55 	{
    56 		Player opponent = new Player();
    57 		Player proponent = new Player();
    58 
    59 		try
    60 		{
    61 			IValue i = new Value(999);
    62 			new Get().returnValue(i, proponent, opponent);
    63 			assertTrue(false);
    64 		}
    65 		catch (ICFPCException e)
    66 		{
    67 			assertTrue(true);
    68 		}
    69 	}
    70 
    71 	@Test
    72 	public final void testIfSlotDead()
    73 	{
    74 		Player opponent = new Player();
    75 		Player proponent = new Player();
    76 
    77 		try
    78 		{
    79 			IValue i = new Value(0);
    80 			proponent.getSlot(((Value)i).getValue()).setVitality(0);
    81 			new Get().returnValue(i, proponent, opponent);
    82 			assertTrue(false);
    83 		}
    84 		catch (ICFPCException e)
    85 		{
    86 			assertTrue(true);
    87 		}
    88 	}
    89 }