Build a simple PhoneBook program.

PhoneBookTest.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class PhoneBookTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class PhoneBookTest
  12. {
  13. PhoneBook pb = new PhoneBook();
  14. @Test
  15. public void PhoneBookAdd(){
  16. String expected = "bobo 333666444";
  17. String actual = pb.add("bobo", "333666444");
  18. assertEquals(expected, actual);
  19. }
  20. @Test
  21. public void PhoneBookRemove(){
  22. String expected = "anything";
  23. String actual = pb.remove("anything");
  24. assertEquals(expected, actual);
  25. }
  26. @Test
  27. public void PhoneBookLookUp(){
  28. //when
  29. pb.add("fufu", "8888888");
  30. //expected
  31. String expected = "8888888";
  32. //actual
  33. String actual = pb.lookUp("fufu");
  34. assertEquals(expected, actual);
  35. }
  36. @Test
  37. public void reverseLookUp(){
  38. //when
  39. pb.add("buu", "89898989");
  40. String expected = "buu";
  41. String actual = pb.reverseLookup("89898989");
  42. assertEquals(expected, actual);
  43. }
  44. @Test
  45. public void DisplayTest(){
  46. //when
  47. }
  48. }