package de.htwg.battleship.objects;

import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 *
 * @author Moritz Sauter (SauterMoritz@gmx.de)
 */
public class FieldTest {
    
    Field field;
    
    public FieldTest() {
    }
    
    @BeforeClass
    public static void setUpClass() {
    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    @Before
    public void setUp() {
        field = new Field(0, 0);
    }
    
    @After
    public void tearDown() {
    }

    @Test
    public void testGetXY() {
        this.field = new Field(5, 9);
        assertEquals(5, field.getX());
        assertEquals(9, field.getY());
        this.field = new Field(2, 3);
        assertEquals(2, field.getX());
        assertEquals(3, field.getY());
    }
    
    /**
     * Test of isHit method, of class Field.
     */
    @Test
    public void testIsHit() {
        this.field = new Field(0, 0);
        boolean expResult = false;
        boolean result = field.isHit();
        assertEquals(expResult, result);
        this.field = new Field(2, 3);
        result = field.isHit();
        assertEquals(expResult, result);
    }

    /**
     * Test of setHit method, of class Field.
     */
    @Test
    public void testSetHit() {
        field.setHit(true);
        assertEquals(field.isHit(), true);
        field.setHit(false);                // Doesn't make sense.
        assertEquals(field.isHit(), true);
        field.setHit(true);
        assertEquals(field.isHit(), true);
        field = new Field(0, 0);
        assertEquals(field.isHit(), false);
        field.setHit(false);
        assertEquals(field.isHit(), false);
    }
    
    @Test(expected = IllegalArgumentException.class)
    public void testIsBetweenXException() {
        field = new Field(-1, 5);
    }
    
    @Test(expected = IllegalArgumentException.class)
    public void testIsBetweenYException() {
        field = new Field(5, 13);
    }
}

@@ -1792,285 +1792,6 @@
    %0A
-    @Test(expected = IllegalArgumentException.class)%0A    public void testIsBetweenXException() %7B%0A        field = new Field(-1, 5);%0A    %7D%0A    %0A    @Test(expected = IllegalArgumentException.class)%0A    public void testIsBetweenYException() %7B%0A        field = new Field(5, 13);%0A    %7D%0A
 %7D%0A

test unnecessary