summaryrefslogtreecommitdiff
path: root/src/Q8/CandidateTest.java
diff options
context:
space:
mode:
authormokha <mokha@cisco.com>2019-05-05 19:57:14 -0600
committermokha <mokha@cisco.com>2019-05-05 19:57:14 -0600
commit7b4cb6a2eef3a0fcde7e998832427c73599e4a0a (patch)
tree75acc7cd8f3bd8a087e909db182c9e18a66879a1 /src/Q8/CandidateTest.java
parent99a28d2dba93642e89a62ecf905a3bd4f138318d (diff)
use the exact naming convention for directories described by instructor
Diffstat (limited to 'src/Q8/CandidateTest.java')
-rw-r--r--src/Q8/CandidateTest.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/Q8/CandidateTest.java b/src/Q8/CandidateTest.java
new file mode 100644
index 0000000..6d2ca5e
--- /dev/null
+++ b/src/Q8/CandidateTest.java
@@ -0,0 +1,62 @@
+package ca.mokhan.assignment1;
+
+import java.util.ArrayList;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class CandidateTest extends TestCase {
+ private Candidate[] candidates = {
+ new Candidate("Elena", "Brandon", 82.30, "poor", true, 0.5),
+ new Candidate("Thomas", "Molson", 85.10, "poor", false, 1.0),
+ new Candidate("Hamilton", "Winn", 77.77, "average", false, 0.8),
+ new Candidate("Suzie", "Sarandin", 69.93, "average", false, 0.0),
+ new Candidate("Philip", "Winne", 93.03, "average", true, 1.0),
+ new Candidate("Alex", "Trebok", 88.61, "poor", true, 0.7),
+ new Candidate("Emma", "Pivoto", 55.99, "excellent", false, 0.8),
+ new Candidate("John", "Lenthen", 87.49, "excellent", true, 0.9),
+ new Candidate("James", "Lean", 88.00, "excellent", false, 0.5),
+ new Candidate("Jane", "Ostin", 91.20, "average", true, 0.6),
+ new Candidate("Emily", "Car", 66.79, "excellent", false, 0.3),
+ new Candidate("Daniel", "Hamshire", 76.65, "average", true, 0.2),
+ new Candidate("Neda", "Bazdar", 55.89, "excellent", true, 0.5),
+ new Candidate("Aaron", "Smith", 90.01, "excellent", false, 0.3),
+ new Candidate("Kate", "Hen", 87.9, "poor", false, 0.8)
+ };
+
+ public CandidateTest(String testName) {
+ super(testName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(CandidateTest.class);
+ }
+
+ public void testGetEligibleCandidates() {
+ ArrayList<Candidate> eligibleCandidates = Candidate.getEligibleCandidates(this.candidates);
+ for (String expected :
+ new String[] {
+ "Hamilton", "Philip", "Alex", "Emma", "John", "James", "Jane", "Neda", "Aaron"
+ }) {
+ assertNotNull(
+ eligibleCandidates.stream()
+ .filter(x -> expected.equals(x.getFirstName()))
+ .findAny()
+ .orElse(null));
+ }
+ }
+
+ public void testIsElligibleWithGreaterThanRequiredGrade() {
+ assertTrue(new Candidate("Tsuyoshi", "Garrett", 85.0, "excellent", false, 0.0).isEligible());
+ }
+
+ public void testIsElligibleWithLessThanRequiredGrade() {
+ assertFalse(new Candidate("Tsuyoshi", "Garrett", 84.9, "average", false, 0.0).isEligible());
+ assertTrue(new Candidate("Tsuyoshi", "Garrett", 84.9, "average", false, 0.5).isEligible());
+ }
+
+ public void testIsElligibleWithPoorCommunication() {
+ assertTrue(new Candidate("Tsuyoshi", "Garrett", 85.0, "poor", true, 0.0).isEligible());
+ assertFalse(new Candidate("Tsuyoshi", "Garrett", 85.0, "poor", false, 0.0).isEligible());
+ }
+}