From 8c0cc67ae30909cc45edcb0a27a29827221008e8 Mon Sep 17 00:00:00 2001 From: Michael Rausch Date: Mon, 6 Mar 2017 19:29:47 +1300 Subject: [PATCH] Add tests for the Leg class Tags: #test #story[4] --- src/test/java/seng302/LegTest.java | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/test/java/seng302/LegTest.java diff --git a/src/test/java/seng302/LegTest.java b/src/test/java/seng302/LegTest.java new file mode 100644 index 00000000..1a5fc90c --- /dev/null +++ b/src/test/java/seng302/LegTest.java @@ -0,0 +1,55 @@ +package seng302; + +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * Unit test for the Leg class. + */ +public class LegTest{ + + /* + Test creation of the leg by specifying a string + for the marker label + */ + @Test + public void testLegCreationUsingMarkerLabel() + { + Leg leg = new Leg(010, 100, "Marker"); + + assertEquals(leg.getHeading(), 010); + assertEquals(leg.getDistance(), 100); + assertEquals(leg.getMarkerLabel(), "Marker"); + assertEquals(leg.getIsFinishingLeg(), false); + } + + /* + Test creation of the leg by providing a + Marker object + */ + @Test + public void testLegCreation() + { + Leg leg = new Leg(010, 100, new Marker("Marker")); + + assertEquals(leg.getHeading(), 010); + assertEquals(leg.getDistance(), 100); + assertEquals(leg.getMarkerLabel(), "Marker"); + assertEquals(leg.getIsFinishingLeg(), false); + } + + /* + Test changing whether or not a + leg is the finishing leg + */ + @Test + public void testSetFinishLeg() + { + Leg leg = new Leg(010, 100, "Marker"); + + leg.setFinishingLeg(true); + assertEquals(leg.getIsFinishingLeg(), true); + } + +}