-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBonusMemberTest.java
130 lines (106 loc) · 3.79 KB
/
BonusMemberTest.java
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package no.ntnu.idata.iir.Joachiam.oblig3;
import static org.junit.jupiter.api.Assertions.*;
import java.time.LocalDate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class BonusMemberTest {
private LocalDate testDate;
private Personals ole;
private Personals tove;
@BeforeEach
void setUp() {
this.testDate = LocalDate.of(2008, 2, 10);
this.ole = new Personals("Ole", "Olsen",
"[email protected]", "ole");
this.tove = new Personals("Tove", "Hansen",
"[email protected]", "tove");
}
/**
* Tests the calculation of points for a basic member Ole.
* User should not be qualified for the upgrade.
*
*/
@Test
void testBasicMemberOle() {
BasicMember b1 = new BasicMember(100, ole,
LocalDate.of(2006, 2, 15));
b1.registerPoints(30000);
System.out.println("Test nr 1: No qualification points");
assertEquals(0, b1.findQualificationPoints(testDate));
assertEquals(30000, b1.getPoints());
System.out.println("Test nr 2: Adding 15 000 points, still no qualification points");
b1.registerPoints(15000);
assertEquals(0, b1.findQualificationPoints(testDate));
assertEquals(45000, b1.getPoints());
}
/**
* Tests a member that should be qualified for a silver and later gold upgrade.
*
*
*/
@Test
void testBasicMemberTove() {
BasicMember b2 = new BasicMember(110, tove,
LocalDate.of(2007, 5, 3));
b2.registerPoints(30000);
System.out.println("Test nr 3: Tove should qualify");
assertEquals(30000, b2.findQualificationPoints(testDate));
assertEquals(30000, b2.getPoints());
System.out.println("Test nr 4: Tove as silver member");
SilverMember b3 = new SilverMember(b2.getMemberNo(), b2.getPersonals(),
b2.getEnrolledDate(), b2.getPoints());
b3.registerPoints(50000);
assertEquals(90000, b3.findQualificationPoints(testDate));
assertEquals(90000, b3.getPoints());
System.out.println("Test nr 5: Tove as gold member");
GoldMember b4 = new GoldMember(b3.getMemberNo(), b3.getPersonals(),
b3.getEnrolledDate(), b3.getPoints());
b4.registerPoints(30000);
assertEquals(135000, b4.findQualificationPoints(testDate));
assertEquals(135000, b4.getPoints());
System.out.println("Test nr 6: Changed test date on Tove");
testDate = LocalDate.of(2008, 10, 12);
// assertEquals( 0, b4.findQualificationPoints(testDate)); Should be 135000??
assertEquals(0, b4.findQualificationPoints(testDate));
assertEquals(135000, b4.getPoints());
}
@org.junit.jupiter.api.Test
void getMemberNo() {
}
@org.junit.jupiter.api.Test
void getPersonals() {
}
@org.junit.jupiter.api.Test
void getEnrolledDate() {
}
@org.junit.jupiter.api.Test
void getPoints() {
}
@org.junit.jupiter.api.Test
void findQualificationPoints() {
}
@org.junit.jupiter.api.Test
void okPassword() {
}
@org.junit.jupiter.api.Test
void getMembershipLevel() {
}
@org.junit.jupiter.api.Test
void compareTo() {
}
@org.junit.jupiter.api.Test
void registerPoints() {
}
/**
* Tests the password for both members.
*
*
*/
@Test
void testPasswords() {
System.out.println("Test nr 7: Trying wrong password on Ole");
assertFalse(ole.okPassword("000"));
System.out.println("Test nr 8: Trying correct password on Tove.");
assertTrue(tove.okPassword("tove"));
}
}