-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathAiSoftwareTest.java
More file actions
97 lines (83 loc) · 3.64 KB
/
AiSoftwareTest.java
File metadata and controls
97 lines (83 loc) · 3.64 KB
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
package object.example.bobbymoney;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class AiSoftwareTest {
@Test
public void constructorShouldSetAllFields() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
assertEquals("Bucky", aiSoftware.getAiName());
assertEquals("Guitar", aiSoftware.getCoachType());
assertEquals("Pomodoro", aiSoftware.getTeachingStyle());
assertEquals(1.0, aiSoftware.getMinimumTimeSpent());
assertEquals("2 weeks", aiSoftware.getTimeFrame());
}
@Test
public void constructorShouldThrowWhenMinimumTimeSpentIsBelowHalfHour() {
assertThrows(IllegalArgumentException.class, () ->
new AiSoftware("Bucky", "Guitar", "Pomodoro", 0.25, "2 weeks")
);
}
@Test
public void setAiNameShouldUpdateAiName() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
aiSoftware.setAiName("Nova");
assertEquals("Nova", aiSoftware.getAiName());
}
@Test
public void setCoachTypeShouldUpdateCoachType() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
aiSoftware.setCoachType("Piano");
assertEquals("Piano", aiSoftware.getCoachType());
}
@Test
public void setTeachingStyleShouldUpdateTeachingStyle() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
aiSoftware.setTeachingStyle("Spaced Repetition");
assertEquals("Spaced Repetition", aiSoftware.getTeachingStyle());
}
@Test
public void setMinimumTimeSpentShouldUpdateValue() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
aiSoftware.setMinimumTimeSpent(2.0);
assertEquals(2.0, aiSoftware.getMinimumTimeSpent());
}
@Test
public void setMinimumTimeSpentShouldThrowWhenBelowHalfHour() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
assertThrows(IllegalArgumentException.class, () ->
aiSoftware.setMinimumTimeSpent(0.1)
);
}
@Test
public void setTimeFrameShouldUpdateTimeFrame() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
aiSoftware.setTimeFrame("1 month");
assertEquals("1 month", aiSoftware.getTimeFrame());
}
@Test
public void getSummaryShouldReturnFormattedString() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
String result = aiSoftware.getSummary();
assertEquals("Bucky is a Guitar coach using the Pomodoro method for 2 weeks.", result);
}
@Test
public void calculateTotalHoursShouldReturnCorrectTotal() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
double total = aiSoftware.calculateTotalHours(5);
assertEquals(5.0, total);
}
@Test
public void calculateTotalHoursShouldThrowWhenSessionsIsZero() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
assertThrows(IllegalArgumentException.class, () ->
aiSoftware.calculateTotalHours(0)
);
}
@Test
public void calculateTotalHoursShouldThrowWhenSessionsIsNegative() {
AiSoftware aiSoftware = new AiSoftware("Bucky", "Guitar", "Pomodoro", 1.0, "2 weeks");
assertThrows(IllegalArgumentException.class, () ->
aiSoftware.calculateTotalHours(-3)
);
}
}