123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class PhoneBookTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class PhoneBookTest
- {
- private PhoneBook phoneBook;
- /**
- * Default constructor for test class PhoneBookTest
- */
- public PhoneBookTest()
- {
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- */
- @Before
- public void setUp()
- {
- phoneBook = new PhoneBook();
- }
-
- @Test
- public void testAdd() {
- //Given
- String name = "J";
- String phoneNumber = "2121112222";
-
- //Then
- phoneBook.addListings(name, phoneNumber);
- int expectedSize = 1;
- int actualSize = phoneBook.size();
-
- //
- assertEquals(expectedSize, actualSize);
- }
-
- @Test
- public void testRemove() {
- //Given
- String name = "J";
- String phoneNumber = "2121112222";
-
- //Then
- phoneBook.addListings(name, phoneNumber);
- int expectedSize = 1;
- int actualSize = phoneBook.size();
-
- //
- assertEquals(expectedSize, actualSize);
- }
-
- @Test
- public void testLookup() {
- //Given
- String name = "J";
- String phoneNumber = "2121112222";
-
- //Then
- phoneBook.addListings(name, phoneNumber);
- int expectedSize = 1;
- int actualSize = phoneBook.size();
-
- //
- assertEquals(expectedSize, actualSize);
- }
-
- @Test
- public void testReverseLookup() {
- //Given
- String name = "J";
- String phoneNumber = "2121112222";
-
- //Then
- phoneBook.addListings(name, phoneNumber);
- int expectedSize = 1;
- int actualSize = phoneBook.size();
-
- //
- assertEquals(expectedSize, actualSize);
- }
-
- @Test
- public void testReverseLookupWhenNotFound() {
- //Given
- String name = "J";
- String phoneNumber = "2121112222";
-
- //Then
- phoneBook.addListings(name, phoneNumber);
- int expectedSize = 1;
- int actualSize = phoneBook.size();
-
- //
- assertEquals(expectedSize, actualSize);
- }
- }
|