Schedule-Creator

Java GUI to create schedules for UNCG students
git clone git://git.wrycode.com/wrycode/archive/Schedule-Creator.git
Log | Files | Refs | README

commit 93cd9592c1cf500685d31fc834f9501b3767dc58
parent 66d90ccae77145c772bc2cb586558a73599530d7
Author: Ilyass Sfar <42755577+cloud0x9@users.noreply.github.com>
Date:   Sat, 18 Apr 2020 15:11:15 -0400

Added a test for email validation (#64)


Diffstat:
MScheduleCreator/Tests.java | 50++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/ScheduleCreator/Tests.java b/ScheduleCreator/Tests.java @@ -21,10 +21,52 @@ public class Tests { //regen databse Admin.regenDB(); - // - //Test api call, - //EmailAdapter testAPI = new EmailAdapter(); - //testAPI.SendEmail("isfar314@gmail.com", "Testing Email API Call"); + + //test validate method + //emailMethodTestData(); + + } + + /** + * Test data for method testing. + */ + private static void emailMethodTestData() { + //edge cases + emailValidationTest(" ", "FAIL"); + emailValidationTest("@", "FAIL"); + emailValidationTest(".com", "FAIL"); + emailValidationTest("@.com", "FAIL"); + emailValidationTest("@.com", "FAIL"); + emailValidationTest("!@#.gov", "FAIL"); + emailValidationTest("123!ABC@test.co", "FAIL"); + emailValidationTest("aBCdE@12AbC.edu", "PASS"); + //normal cases + emailValidationTest("test@test.edu", "PASS"); + emailValidationTest("test@test.gov", "PASS"); + emailValidationTest("123@123.co", "PASS"); + emailValidationTest("ABC@123.io", "PASS"); + emailValidationTest("123@ABC.net", "PASS"); + emailValidationTest("123@ABC.org", "PASS"); + + } + + /** + * Calls the "validate" method with test data and prints what was returned + * and what was expected. + * + * @param _email Email that is being tested for validity. + * @param _expectedResults What the result should be. + * @return + */ + private static String emailValidationTest(String _email, String _expectedResults) { + + if (ScheduleCreator.API.EmailAPI.validate(_email)) { + System.out.println("PASSED : \"" + _email + "\" Is a valid email. EXPECTED: " + _expectedResults); + } else { + System.out.println("FAILED : \"" + _email + "\" Is NOT a valid email. EXPECTED: " + _expectedResults); + } + return null; + } public static void testSemester() throws IOException {