12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- import java.util.*;
-
- /**
- * The test class PhoneBookTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class PhoneBookTest
- {
- private PhoneBook pb = new PhoneBook();
-
- @Before
- public void setup() {
- pb = new PhoneBook();
- }
-
- @Test
- public void addNameStringNumbers() {
- assertEquals(
- pb.add("John", "101-101-1011"),
- new ArrayList<String>(
- Arrays.asList("101-101-1011")
- )
- );
- }
-
- @Test
- public void addNameArrayList() {
- ArrayList<String> numbers = new ArrayList<String>(Arrays.asList(
- "101-101-1011",
- "202-202-2022"
- ));
- assertEquals(
- pb.add("John", numbers),
- numbers
- );
- };
-
- @Test
- public void removeByName() {
- pb.add("John", "101-101-1011");
- pb.remove("John");
-
- assertEquals(
- pb.lookup("John"),
- null
- );
- }
-
- @Test
- public void removeMultipleNumbers() {
- pb.add("John", "101-101-1011");
- pb.add("John", "201-101-1011");
- pb.remove("John", "201-101-1011");
-
- assertEquals(
- pb.lookup("John"),
- new ArrayList<String>(Arrays.asList("101-101-1011"))
- );
- }
-
- @Test
- public void lookup() {
- pb.add("John", "101-101-1011");
- assertEquals(
- pb.lookup("John"),
- new ArrayList<String>(Arrays.asList("101-101-1011"))
- );
- }
-
- @Test
- public void reverseLookup() {
- pb.add("John", "101-101-1011");
- assertEquals(
- pb.reverseLookup("101-101-1011"),
- "John"
- );
- }
- }
|