#ifdef TEST #include "unity.h" #include "createEmployeeAccount.h" void setUp(void) { } void tearDown(void) { } void test_isValidEmployeeID(void) { /*Arrange*/ char* validEmployeeId [] = {"Atharva","Can","Haytham","Julius","Mohamed","Shivam","Fizz","Buzz","JohnDoe","Foobar","waz","Objectoriented","INSTITUTIONALISATIOL","Intercommunicational","1234","1.6"}; int validStringLengths[15]; bool validEmployeeIdExpected = true; for(int i =0;i<15;i++) { validStringLengths[i] = 20; } /*Act and Assert*/ for(int i=0; i<15; i++) { bool validEmployeeIdResult = isValidEmployeeID(validEmployeeId[i],validStringLengths[i]); TEST_ASSERT_EQUAL(validEmployeeIdExpected,validEmployeeIdResult); } } void test_isNotValidEmployeeID(void) { /*Arrange*/ char* invalidEmployeeId [] = {"Atha rva","Ca n","Geschwindigkeitsbegrenzungen","1234 15","John Doe","fizz Fuzz"}; int invalidStringLengths[6]; bool invalidEmployeeIdExpected = false; for(int i =0;i<6;i++) { invalidStringLengths[i] = 20; } /*Act and Assert*/ for(int i=0; i<6; i++) { bool invalidEmployeeIdResult = isValidEmployeeID(invalidEmployeeId[i],invalidStringLengths[i]); TEST_ASSERT_EQUAL(invalidEmployeeIdExpected,invalidEmployeeIdResult); } } void test_employeeCreatedSuccessfully(void) { /*Arrange*/ char* potentialEmployees[][2] = { {"John", "Doe"}, {"Fizz", "Buzz"}, {"Jane", "Doe"}, {"Foo", "Bar"}, {"MusterMann", "MusterManPassword"}, {"MusterFrau", "MusterFrauPassword"} }; bool expected = true; bool result; /*Act and Assert*/ for(int i=0; i<6;i++) { result = createNewEmployee(potentialEmployees[i][0],potentialEmployees[i][1]); TEST_ASSERT_EQUAL(expected,result); } } #endif // TEST