src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java
changeset 97 89f13f209302
parent 46 c592dd7b0595
equal deleted inserted replaced
73:50ef27b8b7dc 97:89f13f209302
     1 package ru.alphatech.icfpc.cards.tests;
     1 package ru.alphatech.icfpc.cards.tests;
     2 
     2 
     3 import static org.junit.Assert.*;
     3 import junit.framework.Assert;
     4 
     4 
     5 import org.junit.Test;
     5 import org.junit.Test;
     6 
     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 
     7 /**
    14 /**
     8  * @author indvdum
    15  * @author indvdum (idea)
       
    16  * @author 0-range (implementation)
     9  * 18.06.2011 19:42:44
    17  * 18.06.2011 19:42:44
    10  *
    18  *
    11  */
    19  */
    12 public class TestGet {
    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 	}
    13 
    34 
    14 	@Test
    35 	@Test
    15 	public final void testReturnValue() {
    36 	public final void testNotSlotNumber()
    16 		assertEquals("test", "test");
    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 		}
    17 	}
    51 	}
    18 
    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 	}
    19 }
    89 }