diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-11-16 02:15:49 -0500 |
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-11-16 02:15:49 -0500 |
| commit | 6ffc6b4cbd9e0c5ce2dc82a7c77f39b3adf849b6 (patch) | |
| tree | 456ed56e629a6324e5993b7ce094705c72e0b922 /src/test/java/design/model/holeplay | |
| parent | 64dd072264dd59457cb195f23d17f03720b1cca0 (diff) | |
| parent | b5d46c7701716bcb2dd6127aeb97f8fcdb7774fc (diff) | |
| download | designproject-design-6-league-model.tar.gz designproject-design-6-league-model.tar.bz2 designproject-design-6-league-model.zip | |
Merge branch 'main' into league-modelleague-model
# Conflicts:
# src/main/java/design/controller/userinput/menus/MainMenu.java
# src/main/java/design/model/Golfer.java
# src/main/java/design/model/ScrambleLeague.java
# src/test/java/design/model/GolferTest.java
# test.xml
Diffstat (limited to '')
| -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 |
