-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryTest.java
More file actions
62 lines (52 loc) · 1.61 KB
/
LibraryTest.java
File metadata and controls
62 lines (52 loc) · 1.61 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
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class LibraryTest {
private Library library = new Library();
private Users users = Users.getInstance();
private ArrayList<User> userList = users.getUsers();
@BeforeEach
public void setup() {
Users.getInstance().getUsers().clear();
DataWriter.saveUsers();
}
@AfterEach
public void tearDown() {
Users.getInstance().getUsers().clear();
DataWriter.saveUsers();
}
@Test
public void testCreateValidAccount() {
library.createAccount("emarks", "Edward", "Marks", 20, "803-454-4455");
library.login("emarks");
User myUser = library.getCurrentUser();
assertEquals("emarks", myUser.getUserName());
}
@Test
public void testCreateSaved() {
library.createAccount("fmarks", "Frank", "Marks", 22, "803-454-4455");
library.logout();
library = new Library();
library.login("fmarks");
User currentUser = library.getCurrentUser();
assertEquals("fmarks", currentUser.getUserName());
}
@Test
public void testCreateDuplicateUserName() {
library.createAccount("emarks", "Edward", "Marks", 20, "803-454-4455");
boolean isCreated = library.createAccount("emarks", "Edwina", "Marks", 30, "803-333-4544");
assertFalse(isCreated);
}
@Test
public void testCreateEmptyUserName() {
boolean isCreated = library.createAccount("", "", "", 0, "");
assertFalse(isCreated);
}
@Test
public void testCreateNullUserName() {
boolean isCreated = library.createAccount(null, "", "", 0, "");
assertFalse(isCreated);
}
}