Tests for BoatInRace, imported Mockito
#test #story[24]
This commit is contained in:
@@ -21,8 +21,17 @@
|
|||||||
<artifactId>gt-referencing</artifactId>
|
<artifactId>gt-referencing</artifactId>
|
||||||
<version>9.0</version>
|
<version>9.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-all</artifactId>
|
||||||
|
<version>1.9.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>maven2-repository.dev.java.net</id>
|
<id>maven2-repository.dev.java.net</id>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class Boat {
|
|||||||
* @return The Name of the boat.
|
* @return The Name of the boat.
|
||||||
*/
|
*/
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return getName().getValue();
|
return getName().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringProperty getVelocityProp() {
|
public StringProperty getVelocityProp() {
|
||||||
|
|||||||
@@ -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"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user