Advertisement
Guest User

Untitled

a guest
Mar 5th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. package tdt4140.gr1855.app.core;
  2. import org.junit.Test;
  3.  
  4. import static org.junit.Assert.assertEquals;
  5.  
  6. import java.io.IOException;
  7. import org.junit.Assert;
  8.  
  9. public class ConstructorTest {
  10.  
  11. //instansiere en eksempellege som kan brukes i alle testene
  12. @Before
  13. public void setUp() {
  14. Doctor lege = new Doctor("Lege Legesen", "lege@gmail.com", "Password2", 44444444);
  15. }
  16. //Teste at navnet kun består av bokstaver
  17. @Test
  18. public void TestNameOnlyContainLetters() {
  19. try {
  20. Patient pasient = new Patient("jak9 Eng", "jak@gmail.com", "Password1", 1997,99999999, lege);
  21. } catch (IllegalArgumentException ex) {
  22.  
  23. }
  24. Assert.fail("expected IllegalArgumentException for name containing invalid elements");
  25. }
  26.  
  27. //teste at navn ikke inneholder flere bokstaver enn to
  28. @Test
  29. public void TestNameIsMoreThanTwoLetters() {
  30. try {
  31. Patient pasient = new Patient("jak E", "jak@gmail.com", "Password1", 1997, 99999999, lege);
  32. } catch (IllegalArgumentException ex) {
  33. } Assert.fail("expected IllegalArgumentException for name having length less than two letters");
  34. }
  35.  
  36. //teste at årstall er mellom 1910 til 2018
  37. @Test
  38. public void TestBirthyearMustBeBetween1910and2018() {
  39. try {
  40. Patient pasient = new Patient("Jak Eng", "jak@gmail.com", "Password1", 1900, 99999999, lege);
  41. } catch (IllegalArgumentException ex) {
  42. }
  43. Assert.fail("expected IllegalArgumentException for birthyear not being between 1910 and 2018");
  44. }
  45. //teste at passordet har lengde åtte
  46. @Test
  47. public void TestPasswordHasCorrectLength() {
  48. try {
  49. Patient pasient = new Patient("Jak Eng", "jak@gmail.com", "Pas1", 1997, 99999999, lege);
  50. } catch (IllegalArgumentException ex) {
  51. }
  52. Assert.fail("expected IllegalArgumentException password must have at least length 8");
  53. }
  54. //minst at passord har minst en stor bokstav,
  55. @Test
  56. public void TestPasswordHasAtLeastOneCapitalLetter() {
  57. try {
  58. Patient pasient = new Patient("Jak Eng", "jak@gmail.com", "password1", 1997, 99999999, lege);
  59. } catch (IllegalArgumentException ex) {
  60. }
  61. Assert.fail("expected IllegalArgumentException password must have at least one capital letter");
  62. }
  63.  
  64. //teste at passord har minst en liten bokstav,
  65. @Test
  66. public void TestPasswordHasAtLeastOneLittleLetter() {
  67. try {
  68. Patient pasient = new Patient("Jak Eng", "jak@gmail.com", "PASSWORD1", 1997, 99999999,lege);
  69. } catch (IllegalArgumentException ex) {
  70. assertEquals(ex.getMessage(), "Passordet må inneholde minst en liten bokstav");
  71. }
  72. Assert.fail("expected IllegalArgumentException password must have at least one small letter");
  73. }
  74.  
  75. //teste at passord har minst ett tall
  76. @Test
  77. public void TestPasswordHasAtLeastOneNumber() {
  78. try {
  79. Patient pasient = new Patient("Jak Eng", "jak@gmail.com", "Password", 1997, 99999999 lege);
  80. } catch (IllegalArgumentException ex) {
  81. }
  82. Assert.fail("expected IllegalArgumentException passwird must contain at least one number");
  83. }
  84. //teste at tlf er åtte siffer
  85. public void TestPhoneNUmberHasEightDigits() {
  86. try {
  87. Patient patient = new Patient("Jak Eng", "jak@gmail.com", "Password1",999, lege);
  88. } catch (IllegalArgumentException e) {
  89.  
  90. }
  91. Assert.fail("expected IllegalArgumentException phone number must have eight digits");
  92. }
  93.  
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement