#story[1101]main
parent
a8701d8a1f
commit
c633de21f5
@ -1,7 +1,156 @@
|
|||||||
package mock.model;
|
package mock.model;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import mock.dataInput.PolarParser;
|
||||||
|
import mock.exceptions.InvalidPolarFileException;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import shared.model.Bearing;
|
||||||
|
import shared.model.GPSCoordinate;
|
||||||
|
import shared.model.Mark;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class MockBoatTest {
|
public class MockBoatTest {
|
||||||
//TODO
|
|
||||||
|
/**
|
||||||
|
* boat made for testing
|
||||||
|
*/
|
||||||
|
private MockBoat firstTestBoat;
|
||||||
|
|
||||||
|
private Mark markToTest;
|
||||||
|
|
||||||
|
private GPSCoordinate highGPS;
|
||||||
|
private GPSCoordinate middleGPS;
|
||||||
|
private GPSCoordinate lowGPS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the Polars object for the tests.
|
||||||
|
*/
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
//Read in polars.
|
||||||
|
try {
|
||||||
|
//Parse data file.
|
||||||
|
Polars polars = PolarParser.parse("mock/polars/acc_polars.csv");
|
||||||
|
|
||||||
|
firstTestBoat = new MockBoat(1, "test", "NZ", polars);
|
||||||
|
highGPS = new GPSCoordinate(100, 100);
|
||||||
|
middleGPS = new GPSCoordinate(100, 75);
|
||||||
|
lowGPS = new GPSCoordinate(100, 50);
|
||||||
|
markToTest = new Mark(1, "test MARK", middleGPS);
|
||||||
|
}
|
||||||
|
catch (InvalidPolarFileException e) {
|
||||||
|
fail("Couldn't parse polar file.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////Mark Higher////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the boat is lower than the mark that the port side method works if
|
||||||
|
* boat is facing east
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsPortSide() {
|
||||||
|
firstTestBoat.setBearing(Bearing.fromDegrees(90));
|
||||||
|
firstTestBoat.setCurrentPosition(lowGPS);
|
||||||
|
markToTest.setPosition(highGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isPortSide(markToTest), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the boat is lower than the mark that the port side method works if
|
||||||
|
* boat is facing west
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsPortSideWrong() {
|
||||||
|
firstTestBoat.setBearing(Bearing.fromDegrees(270));
|
||||||
|
firstTestBoat.setCurrentPosition(lowGPS);
|
||||||
|
markToTest.setPosition(highGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isPortSide(markToTest), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the boat is lower than the mark that the starboard side method works if
|
||||||
|
* boat is facing east
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsStarboardSideWrong() {
|
||||||
|
firstTestBoat.setBearing(Bearing.fromDegrees(90));
|
||||||
|
firstTestBoat.setCurrentPosition(lowGPS);
|
||||||
|
markToTest.setPosition(highGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isStarboardSide(markToTest), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the boat is lower than the mark that the starboard side method works if
|
||||||
|
* boat is facing west
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsStarboardSide() {
|
||||||
|
firstTestBoat.setBearing(Bearing.fromDegrees(270));
|
||||||
|
firstTestBoat.setCurrentPosition(lowGPS);
|
||||||
|
markToTest.setPosition(highGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isStarboardSide(markToTest), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////Mark Lower////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the boat is higher than the mark that the port side method works if
|
||||||
|
* boat is facing east
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsPortSideHigherWrong() {
|
||||||
|
firstTestBoat.setBearing(Bearing.fromDegrees(90));
|
||||||
|
firstTestBoat.setCurrentPosition(highGPS);
|
||||||
|
markToTest.setPosition(lowGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isPortSide(markToTest), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the boat is higher than the mark that the port side method works if
|
||||||
|
* boat is facing west
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsPortSideHigher() {
|
||||||
|
firstTestBoat.setBearing(Bearing.fromDegrees(270));
|
||||||
|
firstTestBoat.setCurrentPosition(highGPS);
|
||||||
|
markToTest.setPosition(lowGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isPortSide(markToTest), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the boat is higher than the mark that the starboard side method works if
|
||||||
|
* boat is facing east
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsStarboardSideHigher() {
|
||||||
|
firstTestBoat.setBearing(Bearing.fromDegrees(90));
|
||||||
|
firstTestBoat.setCurrentPosition(highGPS);
|
||||||
|
markToTest.setPosition(lowGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isStarboardSide(markToTest), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the boat is higher than the mark that the starboard side method works if
|
||||||
|
* boat is facing west
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsStarboardSideHigherWrong() {
|
||||||
|
firstTestBoat.setBearing(Bearing.fromDegrees(270));
|
||||||
|
firstTestBoat.setCurrentPosition(highGPS);
|
||||||
|
markToTest.setPosition(lowGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isStarboardSide(markToTest), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in new issue