-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountTestCases.java
73 lines (60 loc) · 1.88 KB
/
AccountTestCases.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
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
import java.util.ArrayList;
import java.util.Objects;
/**
* AccountTestCases.java
*
* This class tests the methods in Account that are unrelated to GUI
*
* @author Team 060, Section 11
* @version May 03, 2021
* */
public class AccountTestCases {
public static void main(String[] args) {
//An account which will be used for testing
Account testAccount = new Account("[email protected]", "12345678", new ArrayList<Profile>());
//Successful Test cases
try {
testAccount.getEmail();
testAccount.getPassword();
testAccount.getProfiles();
testAccount.setProfiles(new ArrayList<Profile>());
testAccount.addProfile(new Profile());
testAccount.deleteProfile("WillStonebridge");
} catch (Exception e) {
System.out.println("Test Cases Ran incorrectly");
e.printStackTrace();
}
//Test cases that should fail due to incorrect input
int failedCases = 0;
testAccount.setProfiles(null);
try {
testAccount.addProfile(null);
} catch (Exception e) {
failedCases++;
}
try {
testAccount.deleteProfile(null);
} catch (Exception e) {
failedCases++;
}
try {
Objects.requireNonNull(testAccount.getProfiles());
} catch (Exception e) {
failedCases++;
}
testAccount = new Account(null, null, null);
try {
Objects.requireNonNull(testAccount.getEmail());
} catch (Exception e) {
failedCases++;
}
try {
Objects.requireNonNull(testAccount.getPassword());
} catch (Exception e) {
failedCases++;
}
if (failedCases == 5) {
System.out.println("All Test cases ran without issue");
}
}
}