use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testSearchPrevCard.
@SmallTest
@Test
public void testSearchPrevCard() throws Exception {
CardDao cardDao = helper.getCardDao();
Card c = cardDao.searchPrevCard("mouth", 10);
assertEquals(8, (int) c.getId());
c = cardDao.searchPrevCard("%oreille%", 28);
assertEquals(11, (int) c.getId());
c = cardDao.searchPrevCard("whatever", 27);
assertNull(c);
c = cardDao.searchPrevCard("mouth", 8);
assertNull(c);
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testDeleteCardMaintainOrdinal.
@SmallTest
@Test
public void testDeleteCardMaintainOrdinal() throws Exception {
CardDao cardDao = helper.getCardDao();
Card c13 = cardDao.queryForId(13);
Card c14 = cardDao.queryForId(14);
Card c15 = cardDao.queryForId(15);
assertEquals(13, (int) c13.getOrdinal());
assertEquals(14, (int) c14.getOrdinal());
assertEquals(15, (int) c15.getOrdinal());
cardDao.delete(c14);
c13 = cardDao.queryForId(13);
c15 = cardDao.queryForId(15);
assertEquals(13, (int) c13.getOrdinal());
assertEquals(14, (int) c15.getOrdinal());
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testQueryPrevCardWithCategory.
@SmallTest
@Test
public void testQueryPrevCardWithCategory() throws Exception {
setupThreeCategories();
CardDao cardDao = helper.getCardDao();
CategoryDao categoryDao = helper.getCategoryDao();
List<Category> cts = categoryDao.queryForEq("name", "My category");
Category ct = cts.get(0);
Card c5 = cardDao.queryForId(5);
Card c2 = cardDao.queryPrevCard(c5, ct);
assertEquals(2, (int) c2.getId());
Card c8 = cardDao.queryPrevCard(c2, ct);
assertEquals(8, (int) c8.getId());
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testGetById.
@SmallTest
@Test
public void testGetById() {
CardDao cardDao = helper.getCardDao();
Card card = cardDao.getById(3);
assertEquals(3, (int) card.getId());
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class CardDaoTest method testGetCardsForReviewExclusionList.
@SmallTest
@Test
public void testGetCardsForReviewExclusionList() {
// Setup cards that is schedule for review
CardDao cardDao = helper.getCardDao();
Card c13 = cardDao.queryForId(13);
Card c14 = cardDao.queryForId(14);
Card c15 = cardDao.queryForId(15);
LearningDataDao learningDataDao = helper.getLearningDataDao();
Date testDate = new Date((new Date().getTime() - 1));
learningDataDao.refresh(c13.getLearningData());
LearningData c13Ld = c13.getLearningData();
c13Ld.setAcqReps(1);
c13Ld.setNextLearnDate(testDate);
c13Ld.setEasiness((float) 2.8);
learningDataDao.update(c13Ld);
learningDataDao.refresh(c14.getLearningData());
LearningData c14Ld = c14.getLearningData();
c14Ld.setAcqReps(1);
c14Ld.setNextLearnDate(testDate);
c14Ld.setEasiness((float) 2.6);
learningDataDao.update(c14Ld);
learningDataDao.refresh(c15.getLearningData());
LearningData c15Ld = c15.getLearningData();
c15Ld.setAcqReps(1);
c15Ld.setNextLearnDate(testDate);
c15Ld.setEasiness((float) 2.6);
learningDataDao.update(c15Ld);
// Create exclusion list
List<Card> exclusionList = new ArrayList<Card>();
exclusionList.add(c13);
exclusionList.add(c15);
List<Card> cards = cardDao.getCardsForReview(null, exclusionList, 50, ReviewOrdering.HardestFirst);
// Only card 14 is there
assertEquals(1, cards.size());
assertEquals(14, (int) cards.get(0).getId());
}
Aggregations