diff --git a/src/employeeLogin.c b/src/employeeLogin.c index 0d44ddf..dfcac61 100644 --- a/src/employeeLogin.c +++ b/src/employeeLogin.c @@ -1,6 +1,21 @@ #include "mainMenu.h" #include "employeeLogin.h" +bool employeesAccess(char* employeesAccessCode) +{ + + if(strcmp(employeesAccessCode,accessKey) == 0) + { + return true; + } + + else + { + return false; + } + +} + extern int checkEmployeeCredentials(char *inputUsername, char *inputPassword) { diff --git a/src/employeeLogin.h b/src/employeeLogin.h index 485955f..dd77acc 100644 --- a/src/employeeLogin.h +++ b/src/employeeLogin.h @@ -1,10 +1,15 @@ #ifndef LOGINEMPLOYEE_H_ #define LOGINEMPLOYEE_H_ - +#define accessKey "DF9E9A8B5E" #define credentialLength 20 +#include + +bool employeesAccess(char* employeesAccessCode); + int checkEmployeeCredentials(char* username , char* password); + void employeeCredentials(char* username, char* password); void loginAsEmployee(); diff --git a/test/.test_employeeLogin.c.swp b/test/.test_employeeLogin.c.swp deleted file mode 100644 index 7775236..0000000 Binary files a/test/.test_employeeLogin.c.swp and /dev/null differ diff --git a/test/test_employeeLogin.c b/test/test_employeeLogin.c index 8e2d8de..e29bf5d 100644 --- a/test/test_employeeLogin.c +++ b/test/test_employeeLogin.c @@ -108,4 +108,45 @@ void test_MissingLoginEmployee(void) } +void test_validEmployeeAccessCode(void) +{ + //test case 0 + + /*Arrange*/ + + char validAccesscode[11] = "DF9E9A8B5E"; + + /*Act*/ + bool validAccessCodeResult = employeesAccess(validAccesscode); + + /*Assert*/ + + TEST_ASSERT_TRUE(validAccessCodeResult); + +} + +void test_invalidEmployeeAccessCode(void) +{ + //test case 1 + + /*Arrange*/ + + char* invalidAccessCode[] = {"15","foo","fizz","buzz","fizzbuzz","test","bankmanagement"}; + bool invalidCodeResults[7]; + + /*Act*/ + + for(int i=0;i<7;i++) + { + invalidCodeResults[i] = employeesAccess(invalidAccessCode[i]); + } + + /*Assert*/ + + for(int i=0;i<7;i++) + { + TEST_ASSERT_FALSE(invalidCodeResults[i]); + } +} + #endif // TEST