summaryrefslogtreecommitdiff
path: root/src/test/java/design/model/holeplay/HolePlayContextTest.java
blob: a45dccd478a8fba0264797a91393fbb3c2f56b1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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.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();
    // }
}