-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataWriterTest.java
More file actions
83 lines (65 loc) · 2.37 KB
/
Copy pathDataWriterTest.java
File metadata and controls
83 lines (65 loc) · 2.37 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
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class DataWriterTest {
private Users user = Users.getInstance();
private ArrayList<RegisteredUser> userList = new ArrayList<>();
private Users users = Users.getInstance();
private ArrayList<RegisteredUser> userList0 = new ArrayList<>();
private RegistrationInfo regInfo0 = new RegistrationInfo("ben", "s", "bcs11", "password", 19, true);
private UUID uuid0 = new UUID(0, 1);
private BookingList bookList0 = new BookingList();
private ArrayList<PartyMember> partyMemebers0 = new ArrayList<>();
private RegistrationInfo regInfo1 = new RegistrationInfo("bella", "h", "bgh20", "passworddd", 19, true);
private UUID uuid1 = new UUID(0, 1);
private BookingList bookList1 = new BookingList();
private ArrayList<PartyMember> partyMemebers1 = new ArrayList<>();
@BeforeEach
public void setup() {
userList.clear();
userList.add(new RegisteredUser(uuid0, regInfo0, bookList0, partyMemebers0));
userList.add(new RegisteredUser(uuid1, regInfo1, bookList1, partyMemebers1));
}
@AfterEach
public void tearDown() {
Users.getInstance().getRegisteredUsers().clear();
DataWriter.saveUsers();
}
@Test
void tesWritingZeroUsers() {
userList = DataLoader.loadUsers();
assertEquals(0, userList.size());
}
@Test
public void saveUsers() {
assertEquals(true, true);
}
@Test
void testWritingOneUser() {
DataWriter.saveUsers();
assertEquals("tired", DataLoader.loadUsers().get(0).getUserInfo().getUsername());
assertEquals("bcs11", DataLoader.loadUsers().get(0).getUserInfo().getUsername());
}
@Test
void testWritingOneUserAge() {
DataWriter.saveUsers();
assertEquals(20, DataLoader.loadUsers().get(0).getUserInfo().getAge());
assertEquals(-1, DataLoader.loadUsers().get(0).getUserInfo().getAge());
assertEquals(19, DataLoader.loadUsers().get(0).getUserInfo().getAge());
}
@Test
void testWritingEmptyUser() {
DataWriter.saveUsers();
assertEquals("", DataLoader.loadUsers().get(3));
}
@Test
void testWritingNullUser() {
DataWriter.saveUsers();
assertEquals(null, DataLoader.loadUsers().get(3));
}
}