Build a simple PhoneBook program.

PhoneBookTest.java 846B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import org.junit.Assert;
  2. import org.junit.Test;
  3. /**
  4. * The test class PhoneBookTest.
  5. *
  6. * @author (your name)
  7. * @version (a version number or a date)
  8. */
  9. public class PhoneBookTest
  10. {
  11. @Test
  12. public void addEntryTest(){
  13. //Given
  14. PhoneBook phoneBook = new PhoneBook();
  15. String name = "Zebra";
  16. String phoneNumber = "111-222-333";
  17. String expected = "Zebra , 111-222-333";
  18. //When
  19. phoneBook.addEntry(name,phoneNumber);
  20. //Then
  21. Assert.assertEquals(1,phoneBook.size());
  22. }
  23. @Test
  24. public void removeEntry(){
  25. //Given
  26. PhoneBook phoneBook = new PhoneBook();
  27. String name = "Zebra";
  28. String expected = "";
  29. //when
  30. phoneBook.removeEntry(name);
  31. //Then
  32. Assert.assertEquals(0, phoneBook.size());
  33. }
  34. public String lookUp(){
  35. return null;
  36. }
  37. }