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.

93 lines
1.7 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "createEmployeeAccount.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_isValidEmployeeID(void)
  11. {
  12. /*Arrange*/
  13. char* validEmployeeId [] = {"Atharva","Can","Haytham","Julius","Mohamed","Shivam","Fizz","Buzz","JohnDoe","Foobar","waz","Objectoriented","INSTITUTIONALISATIOL","Intercommunicational","1234","1.6"};
  14. bool validEmployeeIdResult[15];
  15. /*Act*/
  16. for(int i=0; i<15; i++)
  17. {
  18. validEmployeeIdResult[i] = isValidEmployeeID(validEmployeeId[i]);
  19. }
  20. /*Assert*/
  21. for(int i =0; i<15;i++)
  22. {
  23. TEST_ASSERT_TRUE(validEmployeeIdResult[i]);
  24. }
  25. }
  26. void test_isNotValidEmployeeID(void)
  27. {
  28. /*Arrange*/
  29. char* invalidEmployeeId [] = {"Atha rva","Ca n","Geschwindigkeitsbegrenzungen","1234 15","John Doe","fizz Fuzz"};
  30. bool invalidEmployeeIdResult[6];
  31. /*Act*/
  32. for(int i=0; i<6; i++)
  33. {
  34. invalidEmployeeIdResult[i] = isValidEmployeeID(invalidEmployeeId[i]);
  35. }
  36. /*Assert*/
  37. for(int i =0; i<6;i++)
  38. {
  39. TEST_ASSERT_FALSE(invalidEmployeeIdResult[i]);
  40. }
  41. }
  42. void test_employeeCreatedSuccessfully(void)
  43. {
  44. /*Arrange*/
  45. char* potentialEmployees[][2] = {
  46. {"John", "Doe"},
  47. {"Fizz", "Buzz"},
  48. {"Jane", "Doe"},
  49. {"Foo", "Bar"},
  50. {"MusterMann", "MusterManPassword"},
  51. {"MusterFrau", "MusterFrauPassword"}
  52. };
  53. bool expected[6] = {true,true,true,true,true,true};
  54. bool result[6];
  55. /*Act*/
  56. for(int i=0; i<6;i++)
  57. {
  58. result[i] = createNewEmployee(potentialEmployees[i][0],potentialEmployees[i][1]);
  59. }
  60. /*Assert*/
  61. for(int i=0; i<6;i++)
  62. {
  63. TEST_ASSERT_EQUAL(expected[i],result[i]);
  64. }
  65. }
  66. #endif // TEST