Test to ensure Feed only accepts INTRA_FEED sort order

This commit is contained in:
orionlee 2019-10-24 12:17:31 -07:00
parent bcd4b49dda
commit 9c895ef15a
1 changed files with 24 additions and 0 deletions

View File

@ -3,10 +3,13 @@ package de.danoeh.antennapod.core.feed;
import org.junit.Before;
import org.junit.Test;
import de.danoeh.antennapod.core.util.SortOrder;
import static de.danoeh.antennapod.core.feed.FeedMother.anyFeed;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class FeedTest {
@ -59,6 +62,27 @@ public class FeedTest {
feedImageWasUpdated();
}
@Test
public void testSetSortOrder_OnlyIntraFeedSortAllowed() throws Exception {
for (SortOrder sortOrder : SortOrder.values()) {
if (sortOrder.scope == SortOrder.Scope.INTRA_FEED) {
original.setSortOrder(sortOrder); // should be okay
} else {
try {
original.setSortOrder(sortOrder);
fail("SortOrder " + sortOrder + " should not be allowed on a feed");
} catch (IllegalArgumentException iae) {
// expected exception
}
}
}
}
@Test
public void testSetSortOrder_NullAllowed() throws Exception {
original.setSortOrder(null); // should be okay
}
private void feedHasNotChanged() {
assertFalse(original.compareWithOther(changedFeed));
}