Search in sources :

Example 1 with QueueManager

use of org.liberty.android.fantastischmemo.queue.QueueManager in project AnyMemo by helloworld1.

the class LearnQueuingManagerTest method testGetNewCardQueuingWithoutCategory.

@SmallTest
@Test
public void testGetNewCardQueuingWithoutCategory() throws Exception {
    QueueManager queueManager = new LearnQueueManager.Builder(getContext(), TestHelper.SAMPLE_DB_PATH).setLearnQueueSize(10).setFilterCategory(null).setCacheSize(50).build();
    Card cqueue = queueManager.dequeue();
    assertEquals(1, (int) cqueue.getId());
    queueManager.release();
}
Also used : LearnQueueManager(org.liberty.android.fantastischmemo.queue.LearnQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) 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 2 with QueueManager

use of org.liberty.android.fantastischmemo.queue.QueueManager in project AnyMemo by helloworld1.

the class QuizQueuingManagerTest method testUpdateCard.

@SmallTest
@Test
public void testUpdateCard() throws Exception {
    Scheduler mockScheduler = mock(Scheduler.class);
    // Create a quiz start the quiz size 3 from card 5
    QueueManager queueManager = new QuizQueueManager.Builder().setDbOpenHelper(helper).setQuizSize(3).setStartCardOrd(5).setScheduler(mockScheduler).build();
    Card card5 = queueManager.dequeue();
    queueManager.remove(card5);
    assertEquals(5, (int) card5.getOrdinal());
    when(mockScheduler.isCardLearned(card5.getLearningData())).thenReturn(true);
    queueManager.update(card5);
    Card card6 = queueManager.dequeue();
    queueManager.remove(card6);
    assertEquals(6, (int) card6.getOrdinal());
    when(mockScheduler.isCardLearned(card6.getLearningData())).thenReturn(false);
    queueManager.update(card6);
    Card card7 = queueManager.dequeue();
    queueManager.remove(card7);
    assertEquals(7, (int) card7.getOrdinal());
    when(mockScheduler.isCardLearned(card7.getLearningData())).thenReturn(true);
    queueManager.update(card7);
    // Now cards in the queue is the card we failed
    // and we succeed this time
    Card card6Again = queueManager.dequeue();
    queueManager.remove(card6Again);
    assertEquals(6, (int) card6Again.getOrdinal());
    when(mockScheduler.isCardLearned(card6.getLearningData())).thenReturn(true);
    queueManager.update(card6Again);
    // No cards in the queue
    Card nullCard = queueManager.dequeue();
    assertNull(nullCard);
}
Also used : Scheduler(org.liberty.android.fantastischmemo.scheduler.Scheduler) QuizQueueManager(org.liberty.android.fantastischmemo.queue.QuizQueueManager) QuizQueueManager(org.liberty.android.fantastischmemo.queue.QuizQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) 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 3 with QueueManager

use of org.liberty.android.fantastischmemo.queue.QueueManager in project AnyMemo by helloworld1.

the class QuizQueuingManagerTest method testFilterByGroup.

@SmallTest
@Test
public void testFilterByGroup() throws Exception {
    // Create a quiz start the quiz size 3 from card 5
    QueueManager queueManager = new QuizQueueManager.Builder().setDbOpenHelper(helper).setQuizSize(3).setStartCardOrd(5).build();
    Card card5 = queueManager.dequeue();
    queueManager.remove(card5);
    assertEquals(5, (int) card5.getOrdinal());
    Card card6 = queueManager.dequeue();
    queueManager.remove(card6);
    assertEquals(6, (int) card6.getOrdinal());
    Card card7 = queueManager.dequeue();
    queueManager.remove(card7);
    assertEquals(7, (int) card7.getOrdinal());
    // No cards in the queue
    Card nullCard = queueManager.dequeue();
    assertNull(nullCard);
}
Also used : QuizQueueManager(org.liberty.android.fantastischmemo.queue.QuizQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) 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 4 with QueueManager

use of org.liberty.android.fantastischmemo.queue.QueueManager in project AnyMemo by helloworld1.

the class LearnQueuingManagerTest method testQueuingPosition.

@SmallTest
@Test
public void testQueuingPosition() throws Exception {
    QueueManager queueManager = new LearnQueueManager.Builder(getContext(), TestHelper.SAMPLE_DB_PATH).setLearnQueueSize(10).setFilterCategory(null).setCacheSize(50).build();
    Card cqueue = queueManager.dequeuePosition(5);
    assertEquals(5, (int) cqueue.getId());
    queueManager.release();
}
Also used : LearnQueueManager(org.liberty.android.fantastischmemo.queue.LearnQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) 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 5 with QueueManager

use of org.liberty.android.fantastischmemo.queue.QueueManager in project AnyMemo by helloworld1.

the class LearnQueuingManagerTest method testUpdate1.

@SmallTest
@Test
public void testUpdate1() throws Exception {
    Scheduler mockScheduler = mock(Scheduler.class);
    QueueManager queueManager = new LearnQueueManager.Builder(getContext(), TestHelper.SAMPLE_DB_PATH).setLearnQueueSize(3).setFilterCategory(null).setScheduler(mockScheduler).setCacheSize(50).build();
    Card c1 = queueManager.dequeue();
    queueManager.remove(c1);
    assertEquals(1, (int) c1.getId());
    when(mockScheduler.isCardLearned(c1.getLearningData())).thenReturn(true);
    updateSucceedCardLearningData(c1);
    queueManager.update(c1);
    Card c2 = queueManager.dequeue();
    queueManager.remove(c2);
    assertEquals(2, (int) c2.getId());
    when(mockScheduler.isCardLearned(c2.getLearningData())).thenReturn(false);
    updateFailureCardLearningData(c2);
    queueManager.update(c2);
    Card c3 = queueManager.dequeue();
    queueManager.remove(c3);
    assertEquals(3, (int) c3.getId());
    when(mockScheduler.isCardLearned(c3.getLearningData())).thenReturn(false);
    updateFailureCardLearningData(c3);
    queueManager.update(c3);
    Card c4 = queueManager.dequeue();
    queueManager.remove(c4);
    assertEquals(4, (int) c4.getId());
    when(mockScheduler.isCardLearned(c4.getLearningData())).thenReturn(true);
    updateSucceedCardLearningData(c4);
    queueManager.update(c4);
    Card c2Again = queueManager.dequeue();
    queueManager.remove(c2Again);
    assertEquals(2, (int) c2Again.getId());
    when(mockScheduler.isCardLearned(c2Again.getLearningData())).thenReturn(true);
    updateSucceedCardLearningData(c2Again);
    queueManager.update(c2Again);
    Card c3Again = queueManager.dequeue();
    queueManager.remove(c3Again);
    assertEquals(3, (int) c3Again.getId());
    when(mockScheduler.isCardLearned(c3Again.getLearningData())).thenReturn(false);
    updateFailureCardLearningData(c3Again);
    queueManager.update(c3Again);
    Card c5 = queueManager.dequeue();
    queueManager.remove(c5);
    assertEquals(5, (int) c5.getId());
    when(mockScheduler.isCardLearned(c5.getLearningData())).thenReturn(false);
    updateFailureCardLearningData(c5);
    queueManager.update(c5);
    queueManager.release();
}
Also used : LearnQueueManager(org.liberty.android.fantastischmemo.queue.LearnQueueManager) Scheduler(org.liberty.android.fantastischmemo.scheduler.Scheduler) LearnQueueManager(org.liberty.android.fantastischmemo.queue.LearnQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) 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

SmallTest (android.support.test.filters.SmallTest)9 Test (org.junit.Test)9 Card (org.liberty.android.fantastischmemo.entity.Card)9 QueueManager (org.liberty.android.fantastischmemo.queue.QueueManager)9 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)9 LearnQueueManager (org.liberty.android.fantastischmemo.queue.LearnQueueManager)6 Scheduler (org.liberty.android.fantastischmemo.scheduler.Scheduler)4 QuizQueueManager (org.liberty.android.fantastischmemo.queue.QuizQueueManager)3 CardDao (org.liberty.android.fantastischmemo.dao.CardDao)2 Category (org.liberty.android.fantastischmemo.entity.Category)2