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.

86 lines
1.9 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. int validStringLengths[15];
  15. bool validEmployeeIdExpected = true;
  16. for(int i =0;i<15;i++)
  17. {
  18. validStringLengths[i] = 20;
  19. }
  20. /*Act and Assert*/
  21. for(int i=0; i<15; i++)
  22. {
  23. bool validEmployeeIdResult = isValidEmployeeID(validEmployeeId[i],validStringLengths[i]);
  24. TEST_ASSERT_EQUAL(validEmployeeIdExpected,validEmployeeIdResult);
  25. }
  26. }
  27. void test_isNotValidEmployeeID(void)
  28. {
  29. /*Arrange*/
  30. char* invalidEmployeeId [] = {"Atha rva","Ca n","Geschwindigkeitsbegrenzungen","1234 15","John Doe","fizz Fuzz"};
  31. int invalidStringLengths[6];
  32. bool invalidEmployeeIdExpected = false;
  33. for(int i =0;i<6;i++)
  34. {
  35. invalidStringLengths[i] = 20;
  36. }
  37. /*Act and Assert*/
  38. for(int i=0; i<6; i++)
  39. {
  40. bool invalidEmployeeIdResult = isValidEmployeeID(invalidEmployeeId[i],invalidStringLengths[i]);
  41. TEST_ASSERT_EQUAL(invalidEmployeeIdExpected,invalidEmployeeIdResult);
  42. }
  43. }
  44. void test_employeeCreatedSuccessfully(void)
  45. {
  46. /*Arrange*/
  47. char* potentialEmployees[][2] = {
  48. {"John", "Doe"},
  49. {"Fizz", "Buzz"},
  50. {"Jane", "Doe"},
  51. {"Foo", "Bar"},
  52. {"MusterMann", "MusterManPassword"},
  53. {"MusterFrau", "MusterFrauPassword"}
  54. };
  55. bool expected = true;
  56. bool result;
  57. /*Act and Assert*/
  58. for(int i=0; i<6;i++)
  59. {
  60. result = createNewEmployee(potentialEmployees[i][0],potentialEmployees[i][1]);
  61. TEST_ASSERT_EQUAL(expected,result);
  62. }
  63. }
  64. #endif // TEST