package sample.sample19;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

public class DataFinderTest {
	private DataFinder dataFinder = new DataFinder();

	@Before
	public void MockのPersonDataAccessorをセット() {
		PersonDataAccessor accessorMock = new PersonDataAccessorMock();
		dataFinder.setAccessor(accessorMock);
	}

	@Test
	public void testFindPerson() {
		List<Person> expected = new ArrayList<Person>();
		expected.add(new Person("佐藤さとこ", "東京都渋谷区", "03-9999-9999"));
		expected.add(new Person("藤原フジ子", "東京都品川区", "03-7777-7777"));

		assertEquals(expected, dataFinder.findPerson("藤"));

		expected = new ArrayList<Person>();
		expected.add(new Person("鈴木すず子", "東京都港区", "03-8888-8888"));
		expected.add(new Person("藤原フジ子", "東京都品川区", "03-7777-7777"));

		assertEquals(expected, dataFinder.findPerson("子"));
	}

	@Test
	public void 検索結果がないパターン() {
		assertEquals(0, dataFinder.findPerson("伊藤").size());
	}

}
