You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/KimberleeObjectTest/HeadPhonesTest.java
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -60,4 +60,30 @@ public void testTurnOff() {
60
60
// Assert
61
61
assertFalse(headphones.isPoweredOn(), "Headphones should turn off after calling");
62
62
}
63
+
64
+
@Test
65
+
publicvoidtestIncreaseVolume() {
66
+
// Arrange
67
+
headphones.turnOn();
68
+
headphones.increaseVolume();
69
+
assertEquals(1, headphones.getVolume(0), "Volume should increase by 1");
70
+
// Act
71
+
headphones.setVolume(99);
72
+
headphones.increaseVolume();
73
+
// Assert
74
+
assertEquals(100, headphones.getVolume(0), "Volume should not exceed 100.");
75
+
}
76
+
77
+
@Test
78
+
publicvoidtestDecreaseVolume() {
79
+
// Arrange
80
+
headphones.turnOn();
81
+
headphones.setVolume(1);
82
+
headphones.decreaseVolume();
83
+
assertEquals(0, headphones.getVolume(0), "Volume should decrease to 0.");
84
+
// Act
85
+
headphones.decreaseVolume();
86
+
// Assert
87
+
assertEquals(0, headphones.getVolume(0), "Volume should not go lower than 0.");
0 commit comments