@Test public void testCombined() { int boxId = insertVocabularyBox( "defaultBox", "English", "German", VocabularyBox.TRANSLATION_DIRECTION_RANDOM); VocabularyBoxCursor boxCursor = new VocabularyBoxCursor( contentProvider.query( RememberMeProvider.VocabularyBox.VOCABULARY_BOXES, null, null, null, null)); assertTrue(boxCursor.moveToFirst()); assertEquals(boxId, boxCursor.peek().id); boxCursor.close(); insertWord(boxId, 1, "porcupine", "Stachelschwein"); WordCursor wordCursor = new WordCursor( contentProvider.query(RememberMeProvider.Word.WORDS, null, null, null, null)); assertTrue(wordCursor.moveToFirst()); int wordId = wordCursor.peek().id; wordCursor.close(); wordCursor = new WordCursor( contentProvider.query( RememberMeProvider.Word.findById(wordId), null, null, null, null)); assertTrue(wordCursor.moveToFirst()); assertEquals(1, wordCursor.peek().compartment); wordCursor.close(); }
@Test public void testWord() { logTime("inside testWord"); WordCursor wordCursor = new WordCursor( contentProvider.query(RememberMeProvider.Word.WORDS, null, null, null, null)); assertFalse(wordCursor.moveToFirst()); wordCursor.close(); logTime("checked no word in db"); int boxId = insertVocabularyBox( "defaultBox", "English", "German", VocabularyBox.TRANSLATION_DIRECTION_RANDOM); logTime("inserted voacabulary box"); insertWord(boxId, 1, "porcupine", "Stachelschwein"); logTime("inserted one word"); wordCursor = new WordCursor( contentProvider.query(RememberMeProvider.Word.WORDS, null, null, null, null)); assertTrue(wordCursor.moveToFirst()); Word word = wordCursor.peek(); logTime("read word"); assertEquals("porcupine", word.foreignWord); assertEquals("Stachelschwein", word.nativeWord); long creationDate = word.creationDate; long now = new Date().getTime(); logInfo("word was created " + (now - creationDate) + " ms ago"); assertTrue(creationDate < now); assertTrue(creationDate + 2000 > now); wordCursor.close(); logTime("end of testWord"); }