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. 46
      tests/test_createEmployeeAccount.c

1
src/employeeList.txt

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

46
tests/test_createEmployeeAccount.c

@ -18,20 +18,14 @@ void test_isValidEmployeeID(void)
/*Arrange*/
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++)
{
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,22 +35,16 @@ void test_isNotValidEmployeeID(void)
/*Arrange*/
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++)
{
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);
}
}
void test_employeeCreatedSuccessfully(void)
@ -71,21 +59,15 @@ void test_employeeCreatedSuccessfully(void)
{"MusterFrau", "MusterFrauPassword"}
};
bool expected[6] = {true,true,true,true,true,true};
bool result[6];
bool expected = true;
bool result;
/*Act*/
/*Act and Assert*/
for(int i=0; i<6;i++)
{
result[i] = createNewEmployee(potentialEmployees[i][0],potentialEmployees[i][1]);
}
/*Assert*/
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