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.

115 lines
2.8 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 validPasswordexpectation = true;
  44. bool validPasswordResult[6];
  45. /*Act and Assert*/
  46. for(int i=0; i<6; i++)
  47. {
  48. validPasswordResult[i] = isValidPassword(validPassword[i],minimalLength);
  49. TEST_ASSERT_EQUAL(validPasswordexpectation,validPasswordResult[i]);
  50. }
  51. }
  52. void test_invalidEmployeePassword(void)
  53. {
  54. /*Arrange*/
  55. char* invalidPassword [] = {"fizzbuzzio","02.09.2023",".^^_*+/-.","RTX4050ti","Can","github.com/bankmanagement-system"};
  56. int minimalLength = 8;
  57. bool invalidPasswordexpected = false;
  58. bool invalidPasswordResult[6];
  59. /*Act and Assert*/
  60. for(int i=0; i<6; i++)
  61. {
  62. invalidPasswordResult[i] = isValidPassword(invalidPassword[i],minimalLength);
  63. TEST_ASSERT_EQUAL(invalidPasswordexpected,invalidPasswordResult[i]);
  64. }
  65. }
  66. void test_employeeCreatedSuccessfully(void)
  67. {
  68. /*Arrange*/
  69. char* potentialEmployees[][2] = {
  70. {"John", "Doe"},
  71. {"Fizz", "Buzz"},
  72. {"Jane", "Doe"},
  73. {"Foo", "Bar"},
  74. {"MusterMann", "MusterManPassword"},
  75. {"MusterFrau", "MusterFrauPassword"}
  76. };
  77. bool expected = true;
  78. bool result;
  79. /*Act and Assert*/
  80. for(int i=0; i<6;i++)
  81. {
  82. result = createNewEmployee(potentialEmployees[i][0],potentialEmployees[i][1]);
  83. TEST_ASSERT_EQUAL(expected,result);
  84. }
  85. }
  86. #endif // TEST