123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
-
-
- 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
- {
- /**
- * Default constructor for test class PhoneBookTest
- */
- public PhoneBookTest(){
- PhoneBook phoneBook = new PhoneBook();
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- */
- @Before
- public void setUp()
- {
- }
- @Test
- public void assTest() {
-
- PhoneBook phoneBook = new PhoneBook();
-
- //given
- phoneBook.add("Ben", "358-1032");
-
- //then
-
- String actual = phoneBook.lookup("Ben");
- String expected = "358-1032";
-
- //assert
-
- assertEquals(expected, actual);
-
- }
- @Test
- public void removeTest() {
- PhoneBook phoneBook = new PhoneBook();
-
- //given
- phoneBook.add("Ben", "358-1032");
- phoneBook.remove("Ben");
-
- //then
- int actual = phoneBook.getSize();
- int expected = 0;
-
- //assert
- assertEquals(expected, actual);
- }
- @Test
- public void reverseLookupTest() {
- PhoneBook phoneBook = new PhoneBook();
-
- //given
- phoneBook.add("Ben", "358-1032");
-
- //then
- String actual = phoneBook.reverseLookup("358-1032");
- String expected = "Ben";
-
- //assert
- assertEquals(expected, actual);
- }
- @Test
- public void displayTest() {
- PhoneBook phoneBook = new PhoneBook();
-
- //given
- phoneBook.add("Ben", "358-1032");
-
- //then
- String actual = phoneBook.display();
- String expected = "Ben : 358-1032";
-
- //assert
- assertEquals(expected, actual);
- }
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @After
- public void tearDown()
- {
- }
- }
|