Package org.scotlandyard.tests.engine.boardmap

Source Code of org.scotlandyard.tests.engine.boardmap.CoordinateTest

package org.scotlandyard.tests.engine.boardmap;


import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.scotlandyard.engine.boardmap.BoardMap;
import org.scotlandyard.engine.boardmap.Coordinate;
import org.scotlandyard.impl.engine.GameEngine;
import org.scotlandyard.impl.engine.boardmap.BoardMapImpl;
import org.scotlandyard.impl.engine.boardmap.CoordinateImpl;

/**
* TODO add description
*
* @author Hussain Al-Mutawa
* @version 1.0
* @since Sept 2011
*
*/
public class CoordinateTest {
  private transient final BoardMap boardMap,boardMap2;
  private transient Coordinate coordinate;
  private transient double latitude,longtitude;
 
  //TODO add description here
  public CoordinateTest() throws Exception {
    boardMap=BoardMapImpl.getNewInstance("Palmerston North");
    boardMap2=BoardMapImpl.getNewInstance("Auckland");
  }

  @Before  //TODO add description of what the test should do
  public void setUp() throws Exception {
    latitude = 10;
    longtitude = 20;
    coordinate = new CoordinateImpl(boardMap,latitude,longtitude);
  }
 
  @After  //TODO add description of what the test should do
  public void tearDown() throws Exception{
    GameEngine.instance().getBoardMaps().remove("Auckland");
  }

  @Test  //TODO add description of what the test should do
  public final void testCompareTo() throws Exception{
    Coordinate coordinate2 = new CoordinateImpl(boardMap, latitude, longtitude);
    Assert.assertEquals(coordinate2.compareTo(coordinate),0);
  }

  @Test(expected=Exception.class)//TODO add description of what the test should do
  public final void testCoordinateImpl() throws Exception{
    Coordinate c = new CoordinateImpl(null,0,0);
    assertNull(c);
  }

  @Test  //TODO add description of what the test should do
  public final void testEqualsObject() throws Exception {
    Coordinate coordinate2 = new CoordinateImpl(boardMap, latitude, longtitude);
    Assert.assertTrue(coordinate2.equals(coordinate));

    Coordinate coordinate3 = new CoordinateImpl(boardMap2, latitude, longtitude);
    Assert.assertFalse(coordinate3.equals(coordinate));
    Assert.assertFalse(coordinate3.equals(coordinate2));

    Coordinate coordinate4 = new CoordinateImpl(boardMap2, latitude, longtitude);
    Assert.assertTrue(coordinate3.equals(coordinate4));

    Assert.assertNotSame(coordinate2.getBoardMap(),coordinate3.getBoardMap());
  }

  @Test  //TODO add description of what the test should do
  public final void testGetBoardMap() {
    Assert.assertSame(coordinate.getBoardMap(),boardMap);
  }

  @Test  //TODO add description of what the test should do
  public final void testGetLabel() {
    Assert.assertEquals("Palmerston North:Coordinate[10.0,20.0]",coordinate.getLabel());
  }

  @Test  //TODO add description of what the test should do
  public final void testGetLatitude() {
    Assert.assertEquals(coordinate.getLatitude(),latitude,0);
  }

  @Test  //TODO add description of what the test should do
  public final void testGetLongitude() {
    Assert.assertEquals(coordinate.getLongtitude(),longtitude,0);
  }

  @Test  //TODO add description of what the test should do
  public final void testSetLabel() {
    coordinate.setLabel("test");
    Assert.assertNotNull(coordinate.getLabel());
    Assert.assertEquals(coordinate.getLabel(),"test");
  }

  @Test  //TODO add description of what the test should do
  public final void testToString() {
    Assert.assertEquals(coordinate.toString(),"{Board Map : [Palmerston North] Coordinate <Latitude=10.0 , Longtitude=20.0>}");
  }

}
TOP

Related Classes of org.scotlandyard.tests.engine.boardmap.CoordinateTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.