forked from Harshil1823/Learning-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserTest.java
More file actions
54 lines (47 loc) · 1.59 KB
/
UserTest.java
File metadata and controls
54 lines (47 loc) · 1.59 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
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
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;
public class UserTest {
@BeforeClass
public void oneTimeSetup() {
}
@AfterClass
public void oneTimeTearDown() {
}
@BeforeEach
public void setup() {
}
@AfterEach
public void tearDown() {
//runs after each test
}
@Test
public void testGetFirstNameWithValidName() {
User user = new User("John", "Doe", "johndoe@example.com", "1234567890", "johndoe", "password", "1234", "no");
assertEquals("John", user.getFirstName());
}
@Test
public void testGetFirstNameWithNullUsername() {
User user = new User(null, "Doe", "johndoe@example.com", "1234567890", null, "password", "1234", "no");
assertEquals("", user.getFirstName());
}
@Test
public void testGetFirstNameWithEmptyName() {
User user = new User("", "", "johndoe@example.com", "1234567890", "johndoe", "password", "1234", "no");
assertEquals("", user.getFirstName());
}
@Test
public void testGetLastNameReturnsLastName() {
User user = new User("John", "Doe", "johndoe@example.com", "555-555-5555", "johndoe", "password", "12345", "no");
assertEquals("Doe", user.getLastName());
}
@Test
public void testGetLastNameReturnsEmptyStringWhenUsernameIsNull() {
User user = new User(null, null, null, null, null, null, null, null);
assertEquals("", user.getLastName());
}
}