Simple Phonebook

PhoneBookTest.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import org.junit.Assert;
  2. import org.junit.Test;
  3. import java.util.Map;
  4. import java.util.TreeMap;
  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. @Test
  14. public void addEntryTest(){
  15. //Given
  16. PhoneBook phoneBook = new PhoneBook();
  17. String name = "Zebra";
  18. String phoneNumber = "111-222-333";
  19. String expected = "Zebra , 111-222-333";
  20. //When
  21. phoneBook.addEntry(name,phoneNumber);
  22. //Then
  23. Assert.assertEquals(1,phoneBook.size());
  24. }
  25. @Test
  26. public void removeEntry(){
  27. //Given
  28. PhoneBook phoneBook = new PhoneBook();
  29. String name = "Zebra";
  30. String expected = "";
  31. //when
  32. phoneBook.removeEntry(name);
  33. //Then
  34. Assert.assertEquals(0, phoneBook.size());
  35. }
  36. @Test
  37. public void lookUp(){
  38. PhoneBook phoneBook = new PhoneBook();
  39. String name = "Zebra";
  40. String expected = "111-222-333";
  41. phoneBook.addEntry(name,expected);
  42. //when
  43. String actual = phoneBook.lookUp(name);
  44. //then
  45. Assert.assertEquals(expected,actual);
  46. }
  47. @Test
  48. public void reverseLoopUp(){
  49. PhoneBook phoneBook = new PhoneBook();
  50. String phoneNumber = "111-222-333";
  51. String expected = "Zebra";
  52. //when
  53. // String actual = phoneBook.reverseLookUp(phoneNumber);
  54. //then
  55. // Assert.assertEquals(expected,actual);
  56. }
  57. @Test
  58. public void display(){
  59. }
  60. }