Search in sources :

Example 36 with Card

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());
}
Also used : ArrayList(java.util.ArrayList) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 37 with Card

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());
}
Also used : CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 38 with Card

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());
}
Also used : CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 39 with Card

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());
}
Also used : CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 40 with Card

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());
}
Also used : CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Aggregations

Card (org.liberty.android.fantastischmemo.entity.Card)95 CardDao (org.liberty.android.fantastischmemo.dao.CardDao)61 SmallTest (android.support.test.filters.SmallTest)43 Test (org.junit.Test)43 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)41 Category (org.liberty.android.fantastischmemo.entity.Category)30 AnyMemoDBOpenHelper (org.liberty.android.fantastischmemo.common.AnyMemoDBOpenHelper)28 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)25 CategoryDao (org.liberty.android.fantastischmemo.dao.CategoryDao)20 LearningDataDao (org.liberty.android.fantastischmemo.dao.LearningDataDao)13 File (java.io.File)12 ArrayList (java.util.ArrayList)11 SQLException (java.sql.SQLException)9 QueueManager (org.liberty.android.fantastischmemo.queue.QueueManager)9 IOException (java.io.IOException)6 Date (java.util.Date)6 LearnQueueManager (org.liberty.android.fantastischmemo.queue.LearnQueueManager)6 URL (java.net.URL)5 FileWriter (java.io.FileWriter)4 Scheduler (org.liberty.android.fantastischmemo.scheduler.Scheduler)4