Separate method pullImageUrlsFromNetwork to allow testing

This commit is contained in:
inorichi
2015-10-09 13:38:28 +02:00
parent ea8ded549b
commit e7ecfd1e84
3 changed files with 53 additions and 45 deletions

View File

@ -2,6 +2,8 @@ package eu.kanade.mangafeed;
import android.os.Build;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -9,10 +11,15 @@ import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.List;
import eu.kanade.mangafeed.data.caches.CacheManager;
import eu.kanade.mangafeed.data.helpers.NetworkHelper;
import eu.kanade.mangafeed.data.models.Manga;
import eu.kanade.mangafeed.sources.Batoto;
import rx.android.schedulers.AndroidSchedulers;
import rx.observers.TestSubscriber;
import rx.schedulers.Schedulers;
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
@RunWith(RobolectricGradleTestRunner.class)
@ -32,9 +39,17 @@ public class BatotoTest {
@Test
public void testImageList() {
TestSubscriber a = new TestSubscriber();
List<String> imageUrls = b.getImageUrlsFromNetwork(chapterUrl)
.toList().toBlocking().single();
b.pullImageUrlsFromNetwork(chapterUrl).subscribe(a);
a.assertNoErrors();
Assert.assertTrue(imageUrls.size() > 5);
}
@Test
public void testMangaList() {
List<Manga> mangaList = b.pullPopularMangasFromNetwork(1)
.toBlocking().first();
Assert.assertTrue(mangaList.size() > 25);
}
}