use of android.support.test.filters.SmallTest 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());
}
use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.
the class CardDaoTest method testSearchFirstOrdinalWithcategoryIfExists.
@SmallTest
@Test
public void testSearchFirstOrdinalWithcategoryIfExists() 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 c = cardDao.queryFirstOrdinal(ct);
assertEquals(2, (int) c.getId());
}
use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.
the class CardDaoTest method testGetRandomCardsWithCategory.
@SmallTest
@Test
public void testGetRandomCardsWithCategory() throws Exception {
CardDao cardDao = helper.getCardDao();
CategoryDao categoryDao = helper.getCategoryDao();
setupThreeCategories();
Category filterCategory1 = categoryDao.createOrReturn("My category");
// larger than limit
List<Card> cards1 = cardDao.getRandomCards(filterCategory1, 50);
assertEquals(3, cards1.size());
// smaller than limit
List<Card> cards2 = cardDao.getRandomCards(filterCategory1, 1);
assertEquals(1, cards2.size());
}
use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.
the class CardDaoTest method testQueryNextCardWithCategory.
@SmallTest
@Test
public void testQueryNextCardWithCategory() 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 c2 = cardDao.queryForId(2);
Card c5 = cardDao.queryNextCard(c2, ct);
assertEquals(5, (int) c5.getId());
Card c8 = cardDao.queryForId(8);
c2 = cardDao.queryNextCard(c8, ct);
assertEquals(2, (int) c2.getId());
}
use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.
the class CategoryTest method testAddCategories.
@SmallTest
@Test
public void testAddCategories() throws Exception {
CategoryDao categoryDao = helper.getCategoryDao();
List<Category> categories = categoryDao.queryForAll();
int initSize = categories.size();
Category c1 = categoryDao.createOrReturn("c1");
assertNotNull(c1);
assertEquals(c1.getName(), "c1");
categories = categoryDao.queryForAll();
assertEquals(categories.size(), initSize + 1);
Category c2 = categoryDao.createOrReturn("c1");
assertEquals(c2.getName(), "c1");
assertEquals(categories.size(), initSize + 1);
}
Aggregations