use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testGetNewCardsWithExclusionList.
@SmallTest
@Test
public void testGetNewCardsWithExclusionList() {
CardDao cardDao = helper.getCardDao();
Card c2 = cardDao.queryForId(2);
Card c5 = cardDao.queryForId(5);
Card c8 = cardDao.queryForId(8);
List<Card> exclusionList = new ArrayList<Card>();
exclusionList.add(c2);
exclusionList.add(c5);
exclusionList.add(c8);
List<Card> cards = cardDao.getNewCards(null, exclusionList, 10);
assertEquals(10, cards.size());
for (Card c : cards) {
if (c.getId() == 2 || c.getId() == 5 || c.getId() == 8) {
fail("Get excluded cards: " + c.getId());
}
}
List<Card> cards2 = cardDao.getNewCards(null, exclusionList, 50);
// 3 cards are excluded so only 28 - 3 = 25 cards are there
assertEquals(25, cards2.size());
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testGetByOrdinal.
@SmallTest
@Test
public void testGetByOrdinal() {
CardDao cardDao = helper.getCardDao();
Card card = cardDao.getByOrdinal(3);
assertEquals(3, (int) card.getOrdinal());
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testQueryNextCardWithoutCategory.
@SmallTest
@Test
public void testQueryNextCardWithoutCategory() throws Exception {
setupThreeCategories();
CardDao cardDao = helper.getCardDao();
Card c27 = cardDao.queryForId(27);
Card c28 = cardDao.queryNextCard(c27, null);
assertEquals(28, (int) c28.getOrdinal());
Card c1 = cardDao.queryNextCard(c28, null);
assertEquals(1, (int) c1.getOrdinal());
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testSwapAllQA.
@SmallTest
@Test
public void testSwapAllQA() throws Exception {
CardDao cardDao = helper.getCardDao();
// Randomly sample 2 cards
Card c8 = cardDao.queryForId(8);
Card c18 = cardDao.queryForId(18);
String question8 = c8.getQuestion();
String answer8 = c8.getAnswer();
String question18 = c18.getQuestion();
String answer18 = c18.getAnswer();
cardDao.swapAllQA();
c8 = cardDao.queryForId(8);
c18 = cardDao.queryForId(18);
assertEquals(answer8, c8.getQuestion());
assertEquals(question8, c8.getAnswer());
assertEquals(answer18, c18.getQuestion());
assertEquals(question18, c18.getAnswer());
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testGetRandomCardsWithoutCategory.
@SmallTest
@Test
public void testGetRandomCardsWithoutCategory() throws Exception {
CardDao cardDao = helper.getCardDao();
// limit higher than total number of cards
List<Card> cards = cardDao.getRandomCards(null, 50);
assertEquals(28, cards.size());
// limit lower than total number of cards
List<Card> cards2 = cardDao.getRandomCards(null, 10);
assertEquals(10, cards2.size());
}
Aggregations