1
1
package XboxTest ;
2
2
3
+ import java .io .ByteArrayOutputStream ;
4
+ import java .io .PrintStream ;
5
+ import java .util .HashMap ; // Ensure LoadGame is imported
6
+
3
7
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
8
import static org .junit .jupiter .api .Assertions .assertTrue ;
5
- import static org .junit .jupiter .api .Assertions .fail ; // Ensure LoadGame is imported
9
+ import static org .junit .jupiter .api .Assertions .fail ;
10
+ import org .junit .jupiter .api .Test ;
6
11
7
12
import com .codedifferently .lesson16 .dylans_xbox .LoadGame ;
8
13
import com .codedifferently .lesson16 .dylans_xbox .Xbox ;
9
- import java .io .ByteArrayOutputStream ;
10
- import java .io .PrintStream ;
11
- import java .util .HashMap ;
12
- import org .junit .jupiter .api .Test ;
13
14
14
15
public class XboxTest {
15
16
@@ -49,7 +50,7 @@ public void testXboxModelEnumValues() {
49
50
Xbox .XboxModel [] models = Xbox .XboxModel .values ();
50
51
assertEquals (6 , models .length );
51
52
assertEquals (
52
- Xbox .XboxModel .XBOX360 , models [0 ]); // Fixed: Corrected the first model to match the enum
53
+ Xbox .XboxModel .XBOX360 , models [0 ]);
53
54
assertEquals (Xbox .XboxModel .XBOXSERIESX , models [5 ]);
54
55
}
55
56
@@ -58,9 +59,9 @@ public void testDiskDrive() {
58
59
Xbox xbox =
59
60
new Xbox (
60
61
"XBOXONE" , 400 , "White" , true ,
61
- false ); // Fixed: Set diskDrive to `false` to match the test
62
+ false );
62
63
assertTrue (
63
- xbox .DiskDrive (), "Disk drive should be empty" ); // Fixed: Corrected the assertion syntax
64
+ xbox .DiskDrive (), "Disk drive should be empty" );
64
65
}
65
66
66
67
@ Test
@@ -111,11 +112,8 @@ public void testEjectGame() {
111
112
fail ("Exception occurred while loading games: " + e .getMessage ());
112
113
}
113
114
114
- // Act: Eject a game
115
- // Act: Eject a game
116
115
xbox .ejectGame (1 );
117
116
118
- // Assert: Verify the game was ejected (if needed, check the state of the Xbox object)
119
117
assertTrue (
120
118
!xbox .getGames ().containsKey (1 ), "Game with ID 1 should be removed from the games list." );
121
119
}
@@ -145,4 +143,18 @@ public void testGetPrice() {
145
143
int price = xbox .getPrice ();
146
144
assertEquals (400 , price , "The price should be 400." );
147
145
}
146
+
147
+ @ Test
148
+ public void testGetColor () {
149
+ Xbox xbox = new Xbox ("XBOX360" , 400 , "White" , true , false );
150
+ String color = xbox .getColor ();
151
+ assertEquals ("White" , color , "The color should be White." );
152
+ }
153
+
154
+ @ Test
155
+ public void testDiskDrive () {
156
+ Xbox xbox = new Xbox ("XBOX360" , 400 , "White" , true , false );
157
+ boolean diskDrive = xbox .DiskDrive ();
158
+ assertTrue (diskDrive , "The disk drive should be present." );
159
+ }
148
160
}
0 commit comments