Build a simple PhoneBook program.

PhoneBookTest.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. public class PhoneBookTest
  6. {
  7. @Before
  8. public void setUp(){
  9. PhoneBook pb = new PhoneBook();
  10. }
  11. @Test
  12. public void testAdd1(){
  13. PhoneBook pb = new PhoneBook();
  14. String expected = "123, 456";
  15. pb.addEntrant("John" , "123", "456");
  16. String actual = pb.lookup("John");
  17. assertEquals(expected, actual);
  18. }
  19. @Test
  20. public void testAdd2(){
  21. PhoneBook pb = new PhoneBook();
  22. String expected = "123";
  23. pb.addEntrant("Josh" , "123");
  24. String actual = pb.lookup("Josh");
  25. assertEquals(expected, actual);
  26. }
  27. @Test
  28. public void testRemove(){
  29. PhoneBook pb = new PhoneBook();
  30. String expected = null;
  31. pb.addEntrant("Josh" , "123");
  32. pb.removeEntrant("Josh");
  33. String actual = pb.lookup("Josh");
  34. assertEquals(expected, actual);
  35. }
  36. @Test
  37. public void testLookup(){
  38. PhoneBook pb = new PhoneBook();
  39. String expected = "123, 456, 789";
  40. pb.addEntrant("Josh" , "123", "456", "789");
  41. String actual = pb.lookup("Josh");
  42. assertEquals(expected, actual);
  43. }
  44. @Test
  45. public void testReverseLookup(){
  46. }
  47. }