Build a simple PhoneBook program.

PhoneBookTest.java 950B

1234567891011121314151617181920212223242526272829303132333435363738
  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. @Test
  8. public void testAdd(){
  9. PhoneBook phonebook = new PhoneBook();
  10. String expected = "1234567890";
  11. phonebook.add("tyler",expected);
  12. String actual = phonebook.lookUp("tyler");
  13. assertEquals(actual, expected);
  14. }
  15. @Test
  16. public void testLookUp(){
  17. PhoneBook phonebook = new PhoneBook();
  18. String expected = "1234567890";
  19. phonebook.add("tyler", expected);
  20. String actual = phonebook.lookUp("tyler");
  21. assertEquals(expected, actual);
  22. }
  23. @Test
  24. public void testReverse(){
  25. PhoneBook phonebook = new PhoneBook();
  26. String expected = "tyler";
  27. phonebook.add("tyler", "1234567890");
  28. String actual = phonebook.reverseLookUp("1234567890");
  29. assertEquals(expected, actual);
  30. }
  31. }