mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge branch 'master' into refactor-file-parser
# Conflicts: # src/main/java/seng302/models/GateMark.java
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package seng302;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import org.junit.Test;
|
||||
import seng302.models.Boat;
|
||||
import seng302.models.Colors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by ryan_ on 16/03/2017.
|
||||
*/
|
||||
public class ColorsTest {
|
||||
@Test
|
||||
public void testNextColor() {
|
||||
List<Boat> boats = new ArrayList<>();
|
||||
boats.add(new Boat("Team 1"));
|
||||
boats.add(new Boat("Team 2"));
|
||||
boats.add(new Boat("Team 3"));
|
||||
boats.add(new Boat("Team 4"));
|
||||
boats.add(new Boat("Team 5"));
|
||||
boats.add(new Boat("Team 6"));
|
||||
|
||||
int count = 0;
|
||||
List<Color> enumColors = new ArrayList<>();
|
||||
while (count < 6) {
|
||||
Color color = Colors.getColor();
|
||||
enumColors.add(color);
|
||||
count++;
|
||||
}
|
||||
|
||||
List<Color> boatColors = new ArrayList<>();
|
||||
for (Boat boat : boats) {
|
||||
Color color = boat.getColor();
|
||||
boatColors.add(color);
|
||||
}
|
||||
|
||||
assertEquals(enumColors, boatColors);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package seng302;
|
||||
import org.junit.Test;
|
||||
import seng302.models.Boat;
|
||||
import seng302.models.Event;
|
||||
import seng302.models.Mark;
|
||||
import seng302.models.mark.SingleMark;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -16,14 +16,14 @@ public class EventTest {
|
||||
@Test
|
||||
public void getTimeString() throws Exception {
|
||||
Boat boat = new Boat("testBoat");
|
||||
Event event = new Event(1231242.2, boat, new Mark("mark1"), new Mark("mark2"));
|
||||
Event event = new Event(1231242.2, boat, new SingleMark("mark1"), new SingleMark("mark2"));
|
||||
assertEquals("20:31:242", event.getTimeString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoatHeading() throws Exception {
|
||||
Boat boat = new Boat("testBoat");
|
||||
Event event = new Event(1231242.2, boat, new Mark("mark1", 142.5, 122.1), new Mark("mark2", 121.9,99.2));
|
||||
Event event = new Event(1231242.2, boat, new SingleMark("mark1", 142.5, 122.1), new SingleMark("mark2", 121.9,99.2));
|
||||
|
||||
assertEquals(event.getBoatHeading(), 221.9733862944651, 1e-15);
|
||||
}
|
||||
@@ -31,8 +31,8 @@ public class EventTest {
|
||||
@Test
|
||||
public void testDistanceBetweenMarks() throws Exception {
|
||||
Boat boat = new Boat("testBoat");
|
||||
Event event = new Event(1231242.2, boat, new Mark("mark1", 142.5, 122.1), new Mark("mark2", 121.9,99.2));
|
||||
Event event = new Event(1231242.2, boat, new SingleMark("mark1", 142.5, 122.1), new SingleMark("mark2", 121.9,99.2));
|
||||
|
||||
assertEquals(event.getDistanceBetweenMarks(), 30.80211031731429, 1e-15);
|
||||
assertEquals(event.getDistanceBetweenMarks(), 339059.653830461, 1e-15);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package seng302;
|
||||
|
||||
import org.junit.Test;
|
||||
import seng302.models.Leg;
|
||||
import seng302.models.Mark;
|
||||
import seng302.models.mark.SingleMark;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -17,25 +17,25 @@ public class LegTest {
|
||||
*/
|
||||
@Test
|
||||
public void testLegCreationUsingMarkerLabel() {
|
||||
Leg leg = new Leg(010, 100, "Mark");
|
||||
Leg leg = new Leg(010, 100, "SingleMark");
|
||||
|
||||
assertEquals(leg.getHeading(), 010);
|
||||
assertEquals(leg.getDistance(), 100);
|
||||
assertEquals(leg.getMarkerLabel(), "Mark");
|
||||
assertEquals(leg.getMarkerLabel(), "SingleMark");
|
||||
assertEquals(leg.getIsFinishingLeg(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creation of the leg by providing a
|
||||
* Mark object
|
||||
* SingleMark object
|
||||
*/
|
||||
@Test
|
||||
public void testLegCreation() {
|
||||
Leg leg = new Leg(010, 100, new Mark("Mark"));
|
||||
Leg leg = new Leg(010, 100, new SingleMark("SingleMark"));
|
||||
|
||||
assertEquals(leg.getHeading(), 010);
|
||||
assertEquals(leg.getDistance(), 100);
|
||||
assertEquals(leg.getMarkerLabel(), "Mark");
|
||||
assertEquals(leg.getMarkerLabel(), "SingleMark");
|
||||
assertEquals(leg.getIsFinishingLeg(), false);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class LegTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetFinishLeg() {
|
||||
Leg leg = new Leg(010, 100, "Mark");
|
||||
Leg leg = new Leg(010, 100, "SingleMark");
|
||||
|
||||
leg.setFinishingLeg(true);
|
||||
assertEquals(leg.getIsFinishingLeg(), true);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package seng302.models.mark;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Haoming on 17/3/17.
|
||||
*/
|
||||
public class MarkTest {
|
||||
|
||||
private SingleMark singleMark1;
|
||||
private SingleMark singleMark2;
|
||||
private GateMark gateMark;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.singleMark1 = new SingleMark("testMark_SM1", 12.23234, -34.342);
|
||||
this.singleMark2 = new SingleMark("testMark_SM2", 12.23239, -34.352);
|
||||
this.gateMark = new GateMark("testMark_GM", singleMark1, singleMark2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getName() throws Exception {
|
||||
assertEquals("testMark_SM1", this.singleMark1.getName());
|
||||
assertEquals("testMark_GM", this.gateMark.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMarkType() throws Exception {
|
||||
assertTrue(this.singleMark2.getMarkType() == MarkType.SINGLE_MARK);
|
||||
assertTrue(this.gateMark.getMarkType() == MarkType.GATE_MARK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMarkContent() throws Exception {
|
||||
assertEquals(12.23234, this.singleMark1.getLatitude(), 1e-10);
|
||||
assertEquals(-34.342, this.singleMark1.getLongitude(), 1e-10);
|
||||
assertEquals("testMark_SM1", this.gateMark.getSingleMark1().getName());
|
||||
assertEquals(-34.352, this.gateMark.getSingleMark2().getLongitude(), 1e-10);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user