You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
161 lines
4.0 KiB
161 lines
4.0 KiB
#ifdef TEST
|
|
|
|
#include "unity.h"
|
|
|
|
#include "createEmployeeAccount.h"
|
|
|
|
void setUp(void)
|
|
{
|
|
}
|
|
|
|
void tearDown(void)
|
|
{
|
|
}
|
|
|
|
void test_isValidEmployeeID(void)
|
|
{
|
|
//test case 0
|
|
/*Arrange*/
|
|
|
|
char* validEmployeeId [] = {"Atharva","Can","Haytham","Julius","Mohamed","Shivam","Fizz","Buzz","JohnDoe","Foobar","waz","Objectoriented","INSTITUTIONALISATIOL","Intercommunicational","1234","1.6"};
|
|
int validStringLengths = 20;
|
|
bool validEmployeeIdExpected = true;
|
|
|
|
/*Act and Assert*/
|
|
|
|
for(int i=0; i<15; i++)
|
|
{
|
|
bool validEmployeeIdResult = isValidEmployeeID(validEmployeeId[i],validStringLengths);
|
|
TEST_ASSERT_EQUAL(validEmployeeIdExpected,validEmployeeIdResult);
|
|
}
|
|
}
|
|
|
|
void test_isNotValidEmployeeID(void)
|
|
{
|
|
//test case 1
|
|
/*Arrange*/
|
|
|
|
char* invalidEmployeeId [] = {"Atha rva","Ca n","Geschwindigkeitsbegrenzungen","1234 15","John Doe","fizz Fuzz"};
|
|
int invalidStringLengths = 20;
|
|
bool invalidEmployeeIdExpected = false;
|
|
|
|
/*Act and Assert*/
|
|
|
|
for(int i=0; i<6; i++)
|
|
{
|
|
bool invalidEmployeeIdResult = isValidEmployeeID(invalidEmployeeId[i],invalidStringLengths);
|
|
TEST_ASSERT_EQUAL(invalidEmployeeIdExpected,invalidEmployeeIdResult);
|
|
}
|
|
|
|
}
|
|
|
|
void test_validEmployeePassword(void)
|
|
{
|
|
/*Arrange*/
|
|
|
|
char* validPassword [] = {"Atharva.123","02.September.2023","fdai7207.","array[20]","malloc(20*sizeof(int))","12.2E1234"};
|
|
int minimalLength = 8;
|
|
bool validPasswordexpectation = true;
|
|
bool validPasswordResult[6];
|
|
|
|
/*Act and Assert*/
|
|
|
|
for(int i=0; i<6; i++)
|
|
{
|
|
validPasswordResult[i] = isValidPassword(validPassword[i],minimalLength);
|
|
TEST_ASSERT_EQUAL(validPasswordexpectation,validPasswordResult[i]);
|
|
}
|
|
|
|
}
|
|
|
|
void test_invalidEmployeePassword(void)
|
|
{
|
|
/*Arrange*/
|
|
|
|
char* invalidPassword [] = {"fizzbuzzio","02.09.2023",".^^_*+/-.","RTX4050ti","Can","github.com/bankmanagement-system"};
|
|
int minimalLength = 8;
|
|
bool invalidPasswordexpected = false;
|
|
bool invalidPasswordResult[6];
|
|
|
|
/*Act and Assert*/
|
|
|
|
for(int i=0; i<6; i++)
|
|
{
|
|
invalidPasswordResult[i] = isValidPassword(invalidPassword[i],minimalLength);
|
|
TEST_ASSERT_EQUAL(invalidPasswordexpected,invalidPasswordResult[i]);
|
|
}
|
|
|
|
}
|
|
|
|
void test_verifyPasswordSuccess()
|
|
{
|
|
/*Arrange*/
|
|
|
|
char* password[10] = {"Atharva123.","fdai.7207","fizz.buzz132","23.March.1999","John.doe99","foo/bar2","fizz+3buzz","gitlab2.com","4test:all","WS-2023"};
|
|
char* confirmation[10] = {"Atharva123.","fdai.7207","fizz.buzz132","23.March.1999","John.doe99","foo/bar2","fizz+3buzz","gitlab2.com","4test:all","WS-2023"};
|
|
bool result[10];
|
|
|
|
/*Act*/
|
|
|
|
for(int i=0; i<10; i++)
|
|
{
|
|
result[i] = verifyPassword(password[i],confirmation[i]);
|
|
}
|
|
|
|
/*Assert*/
|
|
|
|
for(int i=0; i<10; i++)
|
|
{
|
|
TEST_ASSERT_TRUE(result[i]);
|
|
}
|
|
}
|
|
|
|
void test_verifyPasswordFailure()
|
|
{
|
|
/*Arrange*/
|
|
|
|
char* password[10] = {"Atharva123.","fdai.7207","fizz.buzz132","23.March.1999","John.doe99","foo/bar2","fizz+3buzz","gitlab2.com","4test:all","WS-2023"};
|
|
char* confirmation[10] = {"Atharva123","fdai.72","invalidPassword","23.May.1999","Jane.doe99","foo*bar3","fizz-3buzz","github.com","4ceedlingtest:all","SS-2023"};
|
|
bool result[10];
|
|
|
|
/*Act*/
|
|
|
|
for(int i=0; i<10; i++)
|
|
{
|
|
result[i] = verifyPassword(password[i],confirmation[i]);
|
|
}
|
|
|
|
/*Assert*/
|
|
|
|
for(int i=0; i<10; i++)
|
|
{
|
|
TEST_ASSERT_FALSE(result[i]);
|
|
}
|
|
}
|
|
|
|
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
|