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()); 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()); 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()); 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()); // Round testRound = new Round(testCourse, LocalDateTime.now(), new Hole(0, 10)); // HolePlayContext testContext = new HolePlayContext(testGolfer, testRound, PersonalDatabase.instance()); // testContext.startHole(); // } }