-
Notifications
You must be signed in to change notification settings - Fork 0
/
activityTest.java
46 lines (32 loc) · 1.05 KB
/
activityTest.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
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class activityTest {
private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
@Test
void testAddStudent() {
// Given
String input = "1\nMohammad\nMakkah";
InputStream in = new ByteArrayInputStream(input.getBytes());
System.setIn(in);
// When
activity.addStudent();
// Then
assertEquals("Mohammad", activity.h.get(1).getName());
assertEquals("Makkah", activity.h.get(1).getAddress());
}
@Test
void testRemoveStudent() {
// Given
String input = "2\n1";
InputStream in = new ByteArrayInputStream(input.getBytes());
System.setIn(in);
// When
activity.removeStudent();
// Then
assertNull(activity.h.get(1));
}
}