Search in sources :

Example 6 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class CardDaoTest method testGetRandomReviewedCards.

@SmallTest
@Test
public void testGetRandomReviewedCards() throws Exception {
    CardDao cardDao = helper.getCardDao();
    List<Card> cards = cardDao.getRandomReviewedCards(null, 10);
    assertEquals(0, cards.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)

Example 7 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class CardDaoTest method testGetScheduledCardCount.

@SmallTest
@Test
public void testGetScheduledCardCount() throws Exception {
    CardDao cardDao = helper.getCardDao();
    assertEquals(0L, cardDao.getScheduledCardCount(null));
    setupThreeCategories();
    CategoryDao categoryDao = helper.getCategoryDao();
    List<Category> cts = categoryDao.queryForEq("name", "My category");
    Category ct = cts.get(0);
    assertEquals(0L, cardDao.getScheduledCardCount(ct));
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) CategoryDao(org.liberty.android.fantastischmemo.dao.CategoryDao) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 8 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class CardDaoTest method testCreateCardMaintainOrdinal.

@SmallTest
@Test
public void testCreateCardMaintainOrdinal() throws Exception {
    CardDao cardDao = helper.getCardDao();
    // Create card has null ordinal, append to the end
    Card nc = new Card();
    assertNull(nc.getOrdinal());
    cardDao.create(nc);
    assertEquals(29, (int) nc.getOrdinal());
    // Create card with an ordinal
    nc = new Card();
    nc.setOrdinal(14);
    cardDao.create(nc);
    Card c13 = cardDao.queryForId(13);
    Card c14 = cardDao.queryForId(14);
    Card c15 = cardDao.queryForId(15);
    assertEquals(13, (int) c13.getOrdinal());
    assertEquals(14, (int) nc.getOrdinal());
    assertEquals(15, (int) c14.getOrdinal());
    assertEquals(16, (int) c15.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 9 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class CardDaoTest method testGetNewCardCount.

@SmallTest
@Test
public void testGetNewCardCount() throws Exception {
    CardDao cardDao = helper.getCardDao();
    assertEquals(28L, cardDao.getNewCardCount(null));
    setupThreeCategories();
    CategoryDao categoryDao = helper.getCategoryDao();
    List<Category> cts = categoryDao.queryForEq("name", "My category");
    Category ct = cts.get(0);
    assertEquals(3L, cardDao.getNewCardCount(ct));
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) CategoryDao(org.liberty.android.fantastischmemo.dao.CategoryDao) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 10 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class CardDaoTest method testCreateCards.

@SmallTest
@Test
public void testCreateCards() throws Exception {
    CardDao cardDao = helper.getCardDao();
    Card c = new Card();
    c.setOrdinal(29);
    c.setCategory(new Category());
    c.setLearningData(new LearningData());
    Card c2 = new Card();
    c2.setOrdinal(30);
    c2.setCategory(new Category());
    c2.setLearningData(new LearningData());
    List<Card> cards = new ArrayList<Card>();
    cards.add(c);
    cards.add(c2);
    cardDao.createCards(cards);
    // Should create two new card
    assertEquals(30, cardDao.countOf());
    // The new card's id and ordinal should be correct
    assertEquals(29, (int) c.getId());
    assertEquals(29, (int) c.getOrdinal());
    assertEquals(30, (int) c2.getId());
    assertEquals(30, (int) c2.getOrdinal());
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) ArrayList(java.util.ArrayList) LearningData(org.liberty.android.fantastischmemo.entity.LearningData) 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

CardDao (org.liberty.android.fantastischmemo.dao.CardDao)66 Card (org.liberty.android.fantastischmemo.entity.Card)61 SmallTest (android.support.test.filters.SmallTest)37 Test (org.junit.Test)37 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)37 AnyMemoDBOpenHelper (org.liberty.android.fantastischmemo.common.AnyMemoDBOpenHelper)28 Category (org.liberty.android.fantastischmemo.entity.Category)27 CategoryDao (org.liberty.android.fantastischmemo.dao.CategoryDao)22 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)15 LearningDataDao (org.liberty.android.fantastischmemo.dao.LearningDataDao)13 File (java.io.File)10 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)6 URL (java.net.URL)5 FileWriter (java.io.FileWriter)4 Date (java.util.Date)4 BufferedWriter (java.io.BufferedWriter)3 PrintWriter (java.io.PrintWriter)3 SAXParser (javax.xml.parsers.SAXParser)3 SAXParserFactory (javax.xml.parsers.SAXParserFactory)3