1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- import java.util.*;
- import java.util.stream.Collectors;
-
- /**
- * The test class PhoneBookTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class PhoneBookTest
- {
- TreeMap<String, String> phonebook = new TreeMap<>();
- PhoneBook pb = new PhoneBook(phonebook);
-
- @Test
- public void testAdd()
- {
- String name = "Ryan";
- String phoneNumber= "123-456-7890";
- pb.add(name, phoneNumber);
- assertFalse(phonebook.isEmpty());
-
- }
-
- @Test
- public void testRemove()
- {
- String name = "Ryan";
- String phoneNumber= "123-456-7890";
- String name1 = "Marcus";
- String phoneNumber1= "650-789-1234";
- pb.add(name, phoneNumber);
-
-
- pb.remove(name);
- assertTrue(phonebook.isEmpty());
-
- }
-
- @Test
- public void testRemoveRecord()
- {
- String name = "Ryan";
- String phoneNumber= "123-456-7890";
-
- pb.add(name, phoneNumber);
- pb.remove(name);
- assertTrue(phonebook.isEmpty());
-
- }
-
- @Test
- public void testLookup()
- {
- String name = "Ryan";
- String phoneNumber= "123-456-7890";
- pb.add(name, phoneNumber);
- Collection<String> expected = phonebook.values();
-
- assertEquals(expected, pb.lookup(name));
- }
-
- @Test
- public void testReverseLookup() {
- String name = "Ryan";
- String phoneNumber= "123-456-7890";
- pb.add(name, phoneNumber);
- Collection<String> expected = phonebook.keySet();
-
- assertEquals(expected, pb.reverseLookup(phoneNumber));
- }
-
- @Test
- public void testDisplay()
- {
- String name = "Ryan";
- String phoneNumber= "123-456-7890";
- pb.add(name, phoneNumber);
- TreeMap<String, String> expected = phonebook;
-
- assertEquals(expected, pb.display());
- }
-
- }
|