示例#1
0
        public List <QuizWord> GetWords(WordList wordList)
        {
            List <WordInfo> wordsToLearn = wordList.GetAllWords().Where(w => w.IsStudied && !w.IsLearned).OrderBy(w => w.Word.Name).ToList();

            DateTime        cutOffDate    = DateTime.UtcNow - WordInfo.TimeToMarkVerified;
            List <WordInfo> wordsToVerify = wordList.GetAllWords().Where(w => w.IsLearned && !w.IsVerified && w.LastEvent.LastStateChange <= cutOffDate).OrderBy(w => w.Word.Name).ToList();

            List <WordInfo> words = wordsToLearn.Concat(wordsToVerify).ToList();

            return(words.Select(w => new QuizWord(w)).ToList());
        }
        public List<QuizWord> GetWords(WordList wordList)
        {
            List<WordInfo> wordsToLearn = wordList.GetAllWords().Where(w => w.IsStudied && !w.IsLearned).OrderBy(w => w.Word.Name).ToList();

            DateTime cutOffDate = DateTime.UtcNow - WordInfo.TimeToMarkVerified;
            List<WordInfo> wordsToVerify = wordList.GetAllWords().Where(w => w.IsLearned && !w.IsVerified && w.LastEvent.LastStateChange <= cutOffDate).OrderBy(w => w.Word.Name).ToList();

            List<WordInfo> words = wordsToLearn.Concat(wordsToVerify).ToList();
            
            return words.Select(w => new QuizWord(w)).ToList();
        }
示例#3
0
        public void TestMixedEventOrder()
        {
            WordList wordList = new WordList();
            Word     word     = wordList.Add("test", "test", "");

            wordList.ResetHistory();

            DateTime utcNow = DateTime.UtcNow;

            word.Events.Add(new WordEvent(utcNow.AddDays(-1), WordEventType.Remembered));
            word.Events.Add(new WordEvent(utcNow.AddDays(-3), WordEventType.Forgotten));
            word.Events.Add(new WordEvent(utcNow.AddDays(-2), WordEventType.Added));

            var      wordListXml = WordListXmlConverter.ConvertToXml(wordList);
            WordList wordList2   = WordListXmlConverter.ConvertToObject(wordListXml);

            List <WordInfo> words2 = wordList2.GetAllWords().ToList();

            Assert.That(words2.Count, Is.EqualTo(1));

            Word word2 = words2[0].Word;

            Assert.That(word2.Events.Count, Is.EqualTo(3));
            Assert.That(word2.Events[0].EventType, Is.EqualTo(WordEventType.Added));
            Assert.That(word2.Events[1].EventType, Is.EqualTo(WordEventType.Forgotten));
            Assert.That(word2.Events[2].EventType, Is.EqualTo(WordEventType.Remembered));
            Assert.That(word2.Events[0].EventDate, Is.EqualTo(utcNow.AddDays(-3)));
            Assert.That(word2.Events[1].EventDate, Is.EqualTo(utcNow.AddDays(-3)));
            Assert.That(word2.Events[2].EventDate, Is.EqualTo(utcNow.AddDays(-1)));
        }
示例#4
0
        public void Test()
        {
            WordList wordList = new WordList();

            wordList.Add("apple", "a round fruit", null);
            wordList.Add("oRRange", "a round citrus fruit", "fruit");

            Assert.That(wordList.GetAllWords().Select(w => w.Word.Name), Is.EquivalentTo(new[] { "apple", "oRRange" }));
            Assert.That(wordList.GetAllTags(), Is.EquivalentTo(new[] { "fruit" }));
            Assert.That(wordList.GetWordsWithTag("fruit").Select(w => w.Word.Name), Is.EquivalentTo(new[] { "oRRange" }));

            wordList.Update("apple", "apple", "a round fruit", "fruit");
            wordList.Update("oRRange", "orange", "a round citrus fruit", "fruit");

            Assert.That(wordList.GetAllWords().Select(w => w.Word.Name), Is.EquivalentTo(new[] { "apple", "orange" }));
            Assert.That(wordList.GetAllTags(), Is.EquivalentTo(new[] { "fruit" }));
            Assert.That(wordList.GetWordsWithTag("fruit").Select(w => w.Word.Name), Is.EquivalentTo(new[] { "apple", "orange" }));

            wordList.MarkTranslation("a round fruit", WordEventType.Remembered);
            WordEvent translationRemenberedEvent = wordList.GetAllTranslations().Single(t => t.Translation == "a round fruit").Events.First().WordEvent;

            Assert.That(translationRemenberedEvent.EventType, Is.EqualTo(WordEventType.Remembered));
            Assert.That(translationRemenberedEvent.Translation, Is.EqualTo("a round fruit"));

            MemoryStream       mem        = new MemoryStream();
            WordListFileParser fileParser = new WordListFileParser();

            fileParser.GenerateZip(wordList, mem);

            WordList wordList2 = fileParser.ParseZip(mem);

            Assert.That(wordList2.GetAllWords().Select(w => w.Word.Name), Is.EquivalentTo(new[] { "apple", "orange" }));
            Assert.That(wordList2.GetAllTags(), Is.EquivalentTo(new[] { "fruit" }));
            Assert.That(wordList2.GetWordsWithTag("fruit").Select(w => w.Word.Name), Is.EquivalentTo(new[] { "apple", "orange" }));

            translationRemenberedEvent = wordList2.GetAllTranslations().Single(t => t.Translation == "a round fruit").Events.First().WordEvent;
            Assert.That(translationRemenberedEvent.EventType, Is.EqualTo(WordEventType.Remembered));
            Assert.That(translationRemenberedEvent.Translation, Is.EqualTo("a round fruit"));
        }