-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageManagerTest.java
More file actions
69 lines (59 loc) · 2.03 KB
/
Copy pathImageManagerTest.java
File metadata and controls
69 lines (59 loc) · 2.03 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
package org.cis1200.hangman;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
import javax.swing.*;
public class ImageManagerTest {
@Test
public void imageLoaderFilePathNull() {
assertThrows(IllegalArgumentException.class, () -> {
String filePath = null;
JLabel img = ImageManager.imageLoader(filePath);
});
}
@Test
public void imageLoaderFilePathNormal() {
String filePath = "files/0.png";
JLabel img = ImageManager.imageLoader(filePath);
assertDoesNotThrow(() -> img);
}
@Test
public void imageLoaderIOExceptionFileNonexistent() {
String filePath = "files/silly.png"; // this file obviously doesn't exist in files
JLabel img = ImageManager.imageLoader(filePath);
assertDoesNotThrow(() -> img, "THERE IS AN ERROR.");
}
@Test
public void imageLoaderFilePathEmpty() {
String filePath = "";
JLabel img = ImageManager.imageLoader(filePath);
assertNull(img);
}
@Test
public void updateImageSuccessful() {
String path = "files/0.png";
JLabel img = new JLabel();
assertDoesNotThrow(() -> ImageManager.updateImage(img, path));
}
@Test
public void updateImageFilePathNull() {
assertThrows(IllegalArgumentException.class, () -> {
String path = null;
JLabel img = new JLabel();
ImageManager.updateImage(img, path);
});
}
@Test
public void updateImageFilePathEmpty() {
assertThrows(IllegalArgumentException.class, () -> {
String path = "";
JLabel img = new JLabel();
ImageManager.updateImage(img, path);
});
}
@Test
public void updateImageIOExceptionFileNonexistent() {
String path = "files/silly.png";
JLabel img = new JLabel();
assertDoesNotThrow(() -> ImageManager.updateImage(img, path), "THERE IS AN ERROR.");
}
}