Browse Source

implement unit tests for the function employeesAccess().

remotes/origin/feature/the-main-menu
fdai7207 2 years ago
parent
commit
4622393844
  1. 15
      src/employeeLogin.c
  2. 7
      src/employeeLogin.h
  3. BIN
      test/.test_employeeLogin.c.swp
  4. 41
      test/test_employeeLogin.c

15
src/employeeLogin.c

@ -1,6 +1,21 @@
#include "mainMenu.h" #include "mainMenu.h"
#include "employeeLogin.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) extern int checkEmployeeCredentials(char *inputUsername, char *inputPassword)
{ {

7
src/employeeLogin.h

@ -1,10 +1,15 @@
#ifndef LOGINEMPLOYEE_H_ #ifndef LOGINEMPLOYEE_H_
#define LOGINEMPLOYEE_H_ #define LOGINEMPLOYEE_H_
#define accessKey "DF9E9A8B5E"
#define credentialLength 20 #define credentialLength 20
#include<stdbool.h>
bool employeesAccess(char* employeesAccessCode);
int checkEmployeeCredentials(char* username , char* password); int checkEmployeeCredentials(char* username , char* password);
void employeeCredentials(char* username, char* password); void employeeCredentials(char* username, char* password);
void loginAsEmployee(); void loginAsEmployee();

BIN
test/.test_employeeLogin.c.swp

41
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 #endif // TEST
Loading…
Cancel
Save