diff options
Diffstat (limited to 'src/test/java/design/model/holeplay')
| -rw-r--r-- | src/test/java/design/model/holeplay/HolePlayContextTest.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/test/java/design/model/holeplay/HolePlayContextTest.java b/src/test/java/design/model/holeplay/HolePlayContextTest.java index de0f1e9..c2ca619 100644 --- a/src/test/java/design/model/holeplay/HolePlayContextTest.java +++ b/src/test/java/design/model/holeplay/HolePlayContextTest.java @@ -1,5 +1,74 @@ package design.model.holeplay; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.util.Date; +import java.time.LocalDateTime; +import java.util.ArrayList; + +import design.model.Golfer; +import design.model.Round; +import design.model.Club.ClubType; +import design.persistence.PersonalDatabase; +import design.model.Course; +import design.model.Hole; +import design.model.Club; + +/** Unit Tests for the HolePlayContext Class. + * @author Willem Dalton + **/ +@Tag("Model-tier") public class HolePlayContextTest { + @Test + void testConstructor() + { + Golfer testGolfer = new Golfer("John Doe", "j_doe", "weback"); + Course testCourse = new Course(0, "Rolling Waves", 67, "Rochester, NY", 0, 0, new ArrayList<Hole>()); + Round testRound = new Round(testCourse, LocalDateTime.now(), new Hole(0, 10)); + HolePlayContext testContext = new HolePlayContext(testGolfer, testRound, PersonalDatabase.instance()); + assertEquals(testGolfer, testContext.getGolfer()); + assertEquals(testRound, testContext.getRound()); + } + + @Test + void testPlay() + { + Golfer testGolfer = new Golfer("John Doe", "j_doe", "weback"); + Course testCourse = new Course(0, "Rolling Waves", 67, "Rochester, NY", 0, 0, new ArrayList<Hole>()); + Round testRound = new Round(testCourse, LocalDateTime.now(), new Hole(0, 10)); + HolePlayContext testContext = new HolePlayContext(testGolfer, testRound, PersonalDatabase.instance()); + testContext.beginNewPlay(0); + Club testClub = new Club("John Doe Inc", "The Slammer", ClubType.DRIVER); + testContext.addSwing(testClub, 100); + assertEquals(1, testContext.getCurrentPlay().getSwingCount()); + assertEquals(100, testContext.getCurrentPlay().getDistance()); + } + + @Test + void testPlayNull() + { + Golfer testGolfer = new Golfer("John Doe", "j_doe", "weback"); + Course testCourse = new Course(0, "Rolling Waves", 67, "Rochester, NY", 0, 0, new ArrayList<Hole>()); + Round testRound = new Round(testCourse, LocalDateTime.now(), new Hole(0, 10)); + HolePlayContext testContext = new HolePlayContext(testGolfer, testRound, PersonalDatabase.instance()); + testContext.beginNewPlay(0); + Club testClub = new Club("John Doe Inc", "The Slammer", ClubType.DRIVER); + testContext.addSwing(testClub, null); + assertEquals(1, testContext.getCurrentPlay().getSwingCount()); + assertEquals(0, testContext.getCurrentPlay().getDistance()); + } + + // @Test + // void testHolePlay() + // { + // Golfer testGolfer = new Golfer("John Doe", "j_doe", "weback"); + // Course testCourse = new Course(0, "Rolling Waves", 67, "Rochester, NY", 0, 0, new ArrayList<Hole>()); + // Round testRound = new Round(testCourse, LocalDateTime.now(), new Hole(0, 10)); + // HolePlayContext testContext = new HolePlayContext(testGolfer, testRound, PersonalDatabase.instance()); + // testContext.startHole(); + // } }
\ No newline at end of file |
