Browse Source

refactoring: replaced 4 arrays in the unit tests of the function storeEmployeeData() with one matrix to avoid repeated code and removed unnecessary lines.

remotes/origin/feature/employees-infos-access
fdai7207 2 years ago
parent
commit
6a1e132e53
  1. 29
      tests/test_createEmployeeAccount.c

29
tests/test_createEmployeeAccount.c

@ -147,29 +147,22 @@ void test_verifyPasswordFailure()
void test_employeesDataStoringSuccess(void)
{
/*Arrange*/
char*data[][4] ={
{"John","Doe","fulda,leipzigerstr12","+4926428421469"},
{"Jane","Done","fulda,leipzigerstr13","+4932517359874"},
{"Foo","Bar","fulda,leipzigerstr14","+4913598765315"},
{"Mustermann","Mustermanpass","fulda,leipzigerstr16","+4938197853812"}
};
bool creationExpectation = true;
char* firstNames[5] = {"John","Jane","Foo","Fizz","Mustermann"};
char* lastNames[5] = {"Doe","Done","Bar","Buzz","Mustermanpass"};
char* adress[5] = {"fulda,leipzigerstr12","fulda,leipzigerstr13","fulda,leipzigerstr14","fulda,leipzigerstr15","fulda,leipzigerstr16"};
char* phoneNumber[5] = {"+4926428421469","+4932517359874","+4913598765315","+4968145725873","+4938197853812"};
bool creationResult[5];
/*Act*/
for(int i=0;i<5;i++)
{
creationResult[i] = storeEmployeeData(firstNames[i],lastNames[i],adress[i],phoneNumber[i]);
}
/*Assert*/
/*Act and Assert*/
for(int i=0;i<5;i++)
for(int i=0;i<4;i++)
{
TEST_ASSERT_TRUE(creationResult[i]);
bool creationResult = storeEmployeeData(data[i][0],data[i][1],data[i][2],data[i][3]);
TEST_ASSERT_EQUAL(creationExpectation,creationResult);
}
}
void test_employeeCreatedSuccessfully(void)

Loading…
Cancel
Save