@@ -0,0 +1,2838 @@
+import android.support.test.filters.SmallTest;%0Aimport android.support.test.runner.AndroidJUnit4;%0A%0Aimport com.hewgill.android.nzsldict.Dictionary;%0Aimport com.hewgill.android.nzsldict.DictItem;%0Aimport com.hewgill.android.nzsldict.FavouritesRepository;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static android.support.test.InstrumentationRegistry.getInstrumentation;%0Aimport static junit.framework.Assert.assertEquals;%0Aimport static junit.framework.Assert.assertNull;%0Aimport static org.junit.Assert.assertNotEquals;%0A%0A@RunWith(AndroidJUnit4.class)%0A@SmallTest%0Apublic class FavouritesRepositoryTest %7B%0A    private FavouritesRepository repo;%0A    static private Dictionary dict;%0A%0A    @BeforeClass%0A    public static void buildDictionary() %7B%0A        dict = new Dictionary(getInstrumentation().getTargetContext());%0A    %7D%0A%0A    @Before%0A    public void createRepository() %7B%0A        repo = new FavouritesRepository(getInstrumentation().getTargetContext());%0A        for (DictItem di : repo.all()) %7B repo.remove(di); %7D%0A    %7D%0A%0A    @After%0A    public void clearResults() %7B%0A        repo = null;%0A    %7D%0A%0A%0A    @Test%0A    public void add__adds_entry() %7B%0A        DictItem di = dict.getWords(%22hello%22).get(0);%0A        repo.add(di);%0A        assert(repo.contains(di));%0A        assertEquals(1, repo.all().size());%0A    %7D%0A%0A    @Test%0A    public void add__does_not_add_duplicates() %7B%0A        DictItem di = dict.getWords(%22hello%22).get(0);%0A        repo.add(di);%0A        repo.add(di);%0A        assertEquals(1, repo.all().size());%0A    %7D%0A%0A    @Test%0A    public void remove__removes_entry() %7B%0A        DictItem di = dict.getWords(%22hello%22).get(0);%0A        repo.add(di);%0A        repo.remove(di);%0A        assert(! repo.contains(di));%0A    %7D%0A%0A    @Test%0A    public void all__lists_entries() %7B%0A        DictItem di1 = dict.getWords(%22hello%22).get(0);%0A        DictItem di2 = dict.getWords(%22world%22).get(0);%0A        repo.add(di1);%0A        repo.add(di2);%0A%0A        assert(repo.all().get(1).equals(di1));%0A        assert(repo.all().get(0).equals(di2));%0A        assertEquals(2, repo.all().size());%0A    %7D%0A%0A    @Test%0A    public void all__ignores_unknown_entries() %7B%0A        DictItem di1 = dict.getWords(%22hello%22).get(0);%0A        DictItem di2 = new DictItem();%0A        repo.add(di1);%0A        repo.add(di2);%0A%0A        assert(repo.all().get(0).equals(di1));%0A        assertEquals(1, repo.all().size());%0A    %7D%0A%0A    @Test%0A    public void contains__matches_existing_item() %7B%0A        DictItem di1 = dict.getWords(%22Hello%22).get(0);%0A        repo.add(di1);%0A        assert(repo.contains(di1));%0A    %7D%0A%0A    @Test%0A    public void contains__ignores_non_existing_item() %7B%0A        DictItem di1 = dict.getWords(%22Hello%22).get(0);%0A        assert(! repo.contains(di1));%0A    %7D%0A%7D%0A

Add unit test coverage of FavouritesRepository