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.

125 lines
2.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. //test case 0
  13. /*Arrange*/
  14. char* validEmployeeId [] = {"Atharva","Can","Haytham","Julius","Mohamed","Shivam","Fizz","Buzz","JohnDoe","Foobar","waz","Objectoriented","INSTITUTIONALISATIOL","Intercommunicational","1234","1.6"};
  15. int validStringLengths = 20;
  16. bool validEmployeeIdExpected = true;
  17. /*Act and Assert*/
  18. for(int i=0; i<15; i++)
  19. {
  20. bool validEmployeeIdResult = isValidEmployeeID(validEmployeeId[i],validStringLengths);
  21. TEST_ASSERT_EQUAL(validEmployeeIdExpected,validEmployeeIdResult);
  22. }
  23. }
  24. void test_isNotValidEmployeeID(void)
  25. {
  26. //test case 1
  27. /*Arrange*/
  28. char* invalidEmployeeId [] = {"Atha rva","Ca n","Geschwindigkeitsbegrenzungen","1234 15","John Doe","fizz Fuzz"};
  29. int invalidStringLengths = 20;
  30. bool invalidEmployeeIdExpected = false;
  31. /*Act and Assert*/
  32. for(int i=0; i<6; i++)
  33. {
  34. bool invalidEmployeeIdResult = isValidEmployeeID(invalidEmployeeId[i],invalidStringLengths);
  35. TEST_ASSERT_EQUAL(invalidEmployeeIdExpected,invalidEmployeeIdResult);
  36. }
  37. }
  38. void test_validEmployeePassword(void)
  39. {
  40. /*Arrange*/
  41. char* validPassword [] = {"Atharva.123","02.September.2023","fdai7207.","array[20]","malloc(20*sizeof(int))","12.2E1234"};
  42. int minimalLength = 8;
  43. bool validPasswordResult[6];
  44. /*Act*/
  45. for(int i=0; i<6; i++)
  46. {
  47. validPasswordResult[i] = isValidPassword(validPassword[i],minimalLength);
  48. }
  49. /*Assert*/
  50. for(int i=0; i<6; i++)
  51. {
  52. TEST_ASSERT_TRUE(validPasswordResult[i]);
  53. }
  54. }
  55. void test_invalidEmployeePassword(void)
  56. {
  57. /*Arrange*/
  58. char* invalidPassword [] = {"fizzbuzzio","02.09.2023",".^^_*+/-.","RTX4050ti","Can","github.com/bankmanagement-system"};
  59. int minimalLength = 8;
  60. bool invalidPasswordResult[6];
  61. /*Act*/
  62. for(int i=0; i<6; i++)
  63. {
  64. invalidPasswordResult[i] = isValidPassword(invalidPassword[i],minimalLength);
  65. }
  66. /*Assert*/
  67. for(int i=0; i<6; i++)
  68. {
  69. TEST_ASSERT_FALSE(invalidPasswordResult[i]);
  70. }
  71. }
  72. void test_employeeCreatedSuccessfully(void)
  73. {
  74. /*Arrange*/
  75. char* potentialEmployees[][2] = {
  76. {"John", "Doe"},
  77. {"Fizz", "Buzz"},
  78. {"Jane", "Doe"},
  79. {"Foo", "Bar"},
  80. {"MusterMann", "MusterManPassword"},
  81. {"MusterFrau", "MusterFrauPassword"}
  82. };
  83. bool expected = true;
  84. bool result;
  85. /*Act and Assert*/
  86. for(int i=0; i<6;i++)
  87. {
  88. result = createNewEmployee(potentialEmployees[i][0],potentialEmployees[i][1]);
  89. TEST_ASSERT_EQUAL(expected,result);
  90. }
  91. }
  92. #endif // TEST