Browse Source

refactoring: clean up duplicated code for the createEmployeeAccount.c unit tests.

remotes/origin/feature/employees-infos-access
fdai7207 2 years ago
parent
commit
b7d38fac5e
  1. 1
      src/employeeList.txt
  2. 44
      tests/test_createEmployeeAccount.c

1
src/employeeList.txt

@ -9,4 +9,3 @@ Julius Insertcatfdai7057
Mohamed MDfdai6618 Mohamed MDfdai6618
Shivam Schivam007fdlt3781 Shivam Schivam007fdlt3781

44
tests/test_createEmployeeAccount.c

@ -18,20 +18,14 @@ void test_isValidEmployeeID(void)
/*Arrange*/ /*Arrange*/
char* validEmployeeId [] = {"Atharva","Can","Haytham","Julius","Mohamed","Shivam","Fizz","Buzz","JohnDoe","Foobar","waz","Objectoriented","INSTITUTIONALISATIOL","Intercommunicational","1234","1.6"}; char* validEmployeeId [] = {"Atharva","Can","Haytham","Julius","Mohamed","Shivam","Fizz","Buzz","JohnDoe","Foobar","waz","Objectoriented","INSTITUTIONALISATIOL","Intercommunicational","1234","1.6"};
bool validEmployeeIdResult[15];
bool validEmployeeIdExpected = true;
/*Act*/
/*Act and Assert*/
for(int i=0; i<15; i++) for(int i=0; i<15; i++)
{ {
validEmployeeIdResult[i] = isValidEmployeeID(validEmployeeId[i]);
}
/*Assert*/
for(int i =0; i<15;i++)
{
TEST_ASSERT_TRUE(validEmployeeIdResult[i]);
bool validEmployeeIdResult = isValidEmployeeID(validEmployeeId[i]);
TEST_ASSERT_EQUAL(validEmployeeIdExpected,validEmployeeIdResult);
} }
} }
@ -41,20 +35,14 @@ void test_isNotValidEmployeeID(void)
/*Arrange*/ /*Arrange*/
char* invalidEmployeeId [] = {"Atha rva","Ca n","Geschwindigkeitsbegrenzungen","1234 15","John Doe","fizz Fuzz"}; char* invalidEmployeeId [] = {"Atha rva","Ca n","Geschwindigkeitsbegrenzungen","1234 15","John Doe","fizz Fuzz"};
bool invalidEmployeeIdResult[6];
bool invalidEmployeeIdExpected = false;
/*Act*/
/*Act and Assert*/
for(int i=0; i<6; i++) for(int i=0; i<6; i++)
{ {
invalidEmployeeIdResult[i] = isValidEmployeeID(invalidEmployeeId[i]);
}
/*Assert*/
for(int i =0; i<6;i++)
{
TEST_ASSERT_FALSE(invalidEmployeeIdResult[i]);
bool invalidEmployeeIdResult = isValidEmployeeID(invalidEmployeeId[i]);
TEST_ASSERT_EQUAL(invalidEmployeeIdExpected,invalidEmployeeIdResult);
} }
} }
@ -71,21 +59,15 @@ void test_employeeCreatedSuccessfully(void)
{"MusterFrau", "MusterFrauPassword"} {"MusterFrau", "MusterFrauPassword"}
}; };
bool expected[6] = {true,true,true,true,true,true};
bool result[6];
/*Act*/
for(int i=0; i<6;i++)
{
result[i] = createNewEmployee(potentialEmployees[i][0],potentialEmployees[i][1]);
}
bool expected = true;
bool result;
/*Assert*/
/*Act and Assert*/
for(int i=0; i<6;i++) for(int i=0; i<6;i++)
{ {
TEST_ASSERT_EQUAL(expected[i],result[i]);
result = createNewEmployee(potentialEmployees[i][0],potentialEmployees[i][1]);
TEST_ASSERT_EQUAL(expected,result);
} }
} }

Loading…
Cancel
Save