parent
288324ace6
commit
df8b711cf5
@ -0,0 +1,116 @@
|
||||
package seng302.Model;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import seng302.GPSCoordinate;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
/**
|
||||
* Created by esa46 on 22/03/17.
|
||||
*/
|
||||
public class BoatInRaceTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueNorthAzimuthReturns0() {
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||
GPSCoordinate endPoint = new GPSCoordinate(50, 0);
|
||||
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||
boat.setCurrentLeg(start);
|
||||
assertEquals(boat.calculateAzimuth(), 0, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthAzimuthReturns180() {
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||
GPSCoordinate endPoint = new GPSCoordinate(-50, 0);
|
||||
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||
boat.setCurrentLeg(start);
|
||||
assertEquals(boat.calculateAzimuth(), 180, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueEastAzimuthReturns90() {
|
||||
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||
GPSCoordinate endPoint = new GPSCoordinate(0, 50);
|
||||
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||
boat.setCurrentLeg(start);
|
||||
assertEquals(boat.calculateAzimuth(), 90, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueWestAzimuthReturnsNegative90() {
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||
GPSCoordinate endPoint = new GPSCoordinate(0, -50);
|
||||
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||
boat.setCurrentLeg(start);
|
||||
assertEquals(boat.calculateAzimuth(), -90, 1e-8);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueNorthHeadingReturns0() {
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
GPSCoordinate startPoint = new GPSCoordinate(10, 0);
|
||||
GPSCoordinate endPoint = new GPSCoordinate(50, 0);
|
||||
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||
boat.setCurrentLeg(start);
|
||||
assertEquals(boat.calculateHeading(), 0, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueEastHeadingReturns90() {
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||
GPSCoordinate endPoint = new GPSCoordinate(0, 50);
|
||||
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||
boat.setCurrentLeg(start);
|
||||
assertEquals(boat.calculateHeading(), 90, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthHeadingReturns180() {
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
GPSCoordinate startPoint = new GPSCoordinate(10, 0);
|
||||
GPSCoordinate endPoint = new GPSCoordinate(-50, 0);
|
||||
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||
boat.setCurrentLeg(start);
|
||||
assertEquals(boat.calculateHeading(), 180, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueWestHeadingReturns270() {
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
GPSCoordinate startPoint = new GPSCoordinate(0, 10);
|
||||
GPSCoordinate endPoint = new GPSCoordinate(0, -50);
|
||||
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||
boat.setCurrentLeg(start);
|
||||
assertEquals(boat.calculateHeading(), 270, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createNewBoatCratesInstanceOfSuperClass() {
|
||||
|
||||
BoatInRace testBoat = new BoatInRace("Boat", 20, Color.ALICEBLUE, "tt");
|
||||
testBoat.setName("Name can change");
|
||||
assertTrue(testBoat instanceof Boat);
|
||||
assertTrue(testBoat.getCurrentLeg() == null);
|
||||
assertTrue(testBoat.getCurrentPosition() == null);
|
||||
assertTrue(testBoat.toString().contains("Name can change"));
|
||||
assertEquals(testBoat.getVelocity(), 20.0);
|
||||
//assertTrue(testBoat.getName().equals("Name can change"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue