diff --git a/project.yml b/project.yml index 51a5a2a..640cb8f 100644 --- a/project.yml +++ b/project.yml @@ -31,13 +31,12 @@ :paths: :test: - - +:test/** - - -:test/support + - +:tests/** + - -:tests/support :source: - src/** - - src/ :support: - - test/support + - tests/support :libraries: [] :defines: diff --git a/src/showGeneralInfoEmployee.c b/src/showGeneralInfoEmployee.c new file mode 100644 index 0000000..25355c9 --- /dev/null +++ b/src/showGeneralInfoEmployee.c @@ -0,0 +1,107 @@ +#include "showGeneralInfoEmployee.h" + +//int checkUser() is helpful for unittesting showGeneralInfoEmployee() +int checkUser(char username[length], char password[length]) +{ + if(strcmp(username,"Atharva")==0 && strcmp(password,"Atharvafdai7514")==0) + { + return 1; + } + + if(strcmp(username,"Can")==0 && strcmp(password,"BlooMaskfdlt3817")==0) + { + return 2; + } + + if(strcmp(username,"Haytham")==0 && strcmp(password,"TimoDLfdai7207")==0) + { + return 3; + } + + if(strcmp(username,"Julius")==0 && strcmp(password,"Insertcatfdai7057")==0) + { + return 4; + } + + if(strcmp(username,"Mohamed")==0 && strcmp(password,"MDfdai6618")==0) + { + return 5; + } + + if(strcmp(username,"Shivam")==0 && strcmp(password,"Schivam007fdlt3781")==0) + { + return 6; + } + + else + { + return 0; + } +} + + +void showGeneralInfoEmployee(char id[length], char password[length]) +{ + // "If Statements" check, whether the username and password match. + + if(checkUser(id, password) == 1) + { + printf(" Welcome Atharva\n"); + printf(" Clearance: 3\n"); + printf("\n"); + printf("\n"); + printf(" ->Review new customer applications.\n"); + } + + if(checkUser(id, password) == 2) + { + printf(" Welcome Can\n"); + printf(" Clearance: 3\n"); + printf("\n"); + printf("\n"); + printf(" ->Review new customer applications.\n"); + } + + if(checkUser(id, password) == 3) + { + printf(" Welcome Haytham\n"); + printf(" Clearance: 2\n"); + printf("\n"); + printf("\n"); + printf(" ->Review new customer applications.\n"); + printf(" ->Review loan applications.\n"); + } + + if(checkUser(id, password) == 4) + { + printf(" Welcome Julius\n"); + printf(" Clearance: 2\n"); + printf("\n"); + printf("\n"); + printf(" ->Review new customer applications.\n"); + printf(" ->Review loan applications.\n"); + } + + if(checkUser(id, password) == 5) + { + printf(" Welcome Mohamed\n"); + printf(" Clearance: 3\n"); + printf("\n"); + printf("\n"); + printf(" ->Review new customer applications.\n"); + printf(" ->Review loan applications.\n"); + printf(" ->Terminate account.\n"); + } + + if(checkUser(id, password) == 6) + { + printf(" Welcome Shivam\n"); + printf(" Clearance: 3\n"); + printf("\n"); + printf("\n"); + printf(" ->Review new customer applications.\n"); + printf(" ->Review loan applications.\n"); + printf(" ->Terminate account.\n"); + } + +} diff --git a/src/showGeneralInfoEmployee.h b/src/showGeneralInfoEmployee.h new file mode 100644 index 0000000..bfedbbe --- /dev/null +++ b/src/showGeneralInfoEmployee.h @@ -0,0 +1,11 @@ +#ifndef SHOWGENERALINFOEMPLOYEE_H +#define SHOWGENERALINFOEMPLOYEE_H + +#include +#include +#include + +const int length = 100; +int checkUser(char username[length], char password[length]); +void showGeneralInfoEmployee(char id[length], char password[length]); +#endif // SHOWGENERALINFOEMPLOYEE_H diff --git a/tests/support/.gitkeep b/tests/support/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_showGeneralInfoEmployee.c b/tests/test_showGeneralInfoEmployee.c new file mode 100644 index 0000000..0d1084c --- /dev/null +++ b/tests/test_showGeneralInfoEmployee.c @@ -0,0 +1,63 @@ +#ifdef TEST + +#include "unity.h" + +#include "showGeneralInfoEmployee.c" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + + +void test1_showGeneralInfoEmployee(void) +{ + char employeeName[] = "Atharva"; //Arrange + char password[] = "Atharvafdai7514"; + int ergebnis = checkUser(employeeName, password); //Act + TEST_ASSERT_EQUAL_INT(1, ergebnis); //Assert +} +void test2_showGeneralInfoEmployee(void) +{ + char employeeName[] = "Can"; //Arrange + char password[] = "BlooMaskfdlt3817"; + int ergebnis = checkUser(employeeName, password); //Act + TEST_ASSERT_EQUAL_INT(2, ergebnis); //Assert +} +void test3_showGeneralInfoEmployee(void) +{ + char employeeName[] = "Haytham"; //Arrange + char password[] = "TimoDLfdai7207"; + int ergebnis = checkUser(employeeName, password); //Act + TEST_ASSERT_EQUAL_INT(3, ergebnis); //Assert +} +void test4_showGeneralInfoEmployee(void) +{ + char employeeName[] = "Julius"; //Arrange + char password[] = "Insertcatfdai7057"; + int ergebnis = checkUser(employeeName, password); //Act + TEST_ASSERT_EQUAL_INT(4, ergebnis); //Assert +} +void test5_showGeneralInfoEmployee(void) +{ + char employeeName[] = "Mohamed"; //Arrange + char password[] = "MDfdai6618"; + int ergebnis = checkUser(employeeName, password); //Act + TEST_ASSERT_EQUAL_INT(5, ergebnis); //Assert +} +void test6_showGeneralInfoEmployee(void) +{ + char employeeName[] = "Shivam"; //Arrange + char password[] = "Schivam007fdlt3781"; + int ergebnis = checkUser(employeeName, password); //Act + TEST_ASSERT_EQUAL_INT(6, ergebnis); //Assert +} + + + + + +#endif // TEST