1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import org.junit.Assert;
  2. import org.junit.Before;
  3. import org.junit.Test;
  4. /**
  5. * Created by leon on 1/24/18.
  6. */
  7. public class PersonHandlerTest {
  8. PersonHandler personHandler;
  9. private String expected;
  10. @Before
  11. public void setup() {
  12. // : Given
  13. Person person1 = new Person("Leon", "Hunter");
  14. Person person2 = new Person("Tariq", "Hook");
  15. Person person3 = new Person("Dolio", "Durant");
  16. Person[] personArray = {person1, person2, person3};
  17. this.personHandler = new PersonHandler(personArray);
  18. this.expected = "\nMy first name is Leon\n" +
  19. "My last name is Hunter\n" +
  20. "My first name is Tariq\n" +
  21. "My last name is Hook\n" +
  22. "My first name is Dolio\n" +
  23. "My last name is Durant";
  24. }
  25. @Test
  26. public void testWhileLoop() {
  27. // : When
  28. String actual = personHandler.whileLoop();
  29. // : Then
  30. Assert.assertEquals(expected, actual);
  31. }
  32. @Test
  33. public void testForLoop() {
  34. // : When
  35. String actual = personHandler.forLoop();
  36. // : Then
  37. Assert.assertEquals(expected, actual);
  38. }
  39. @Test
  40. public void testForEachLoop() {
  41. // : When
  42. String actual = personHandler.forEachLoop();
  43. // : Then
  44. Assert.assertEquals(expected, actual);
  45. }
  46. }