public void Constructor()
        {
            var session = new LearningSession(this.words, this.words, 1);

            MyAssertions.CollectionAssert(this.words, session.Items, (e, a) => e.ID == a.Word.ID);
            Assert.AreEqual(this.words[0].ID, session.CurrentWord.Word.ID);
            Assert.IsNotNull(session.PassedWords);
            Assert.IsNotNull(session.StartTime);
        }
        public void NextCorrect()
        {
            var session = new LearningSession(this.words, this.words, 1);

            session.CurrentWord.Answer = "one";
            var actual = session.Next();

            Assert.AreEqual(LearningSession.NextResult.Correct, actual);
            Assert.IsNull(session.Items.Where(w => w.Word.Spelling == "one").FirstOrDefault());
            Assert.IsNotNull(session.PassedWords.Where(w => w.Spelling == "one").FirstOrDefault());
        }
        public void NextCycling()
        {
            var session = new LearningSession(this.words, this.words, 1);

            session.CurrentWord.Answer = "on";
            session.Next();
            session.CurrentWord.Answer = "one";
            session.Next();
            session.CurrentWord.Answer = "two";
            session.Next();
            session.CurrentWord.Answer = "single";
            session.Next();

            Assert.IsNotNull(session.CurrentWord);
            Assert.AreEqual(words.Where(w => w.Spelling == "one").FirstOrDefault().ID, session.CurrentWord.Word.ID);
        }
예제 #4
0
 protected void UpdateSchedule(LearningSession session)
 {
     foreach (var word in session.PassedWords)
     {
         var existingWordResult = wordResultStorage.AllList.Where(wr => wr.Word.ID == word.ID).FirstOrDefault();
         if (existingWordResult == null)
             wordResultStorage.Add(new WordResult() { Word = word, LearningSchedule = scheduleBuilder.GetSchedule(session.FinishTime).ToList() });
         else
         {
             var scheduleItem = existingWordResult.LearningSchedule.Where(i => i.IsShown == false).OrderBy(i => i.DateToShow).FirstOrDefault();
             if (scheduleItem != null)
             {
                 scheduleItem.IsShown = scheduleItem.IsSuccessful = true;
             }
         }
     }
     wordResultStorage.Save();
     this.Session = null;
 }
        public void NextExpactedOtherVariant()
        {
            var session = new LearningSession(this.words, this.words, 1);

            session.CurrentWord.Answer = "one";
            session.Next();
            session.CurrentWord.Answer = "two";
            session.Next();

            session.CurrentWord.Answer = "one";
            var actual = session.Next();
            var currentWord = session.Items.Where(w => w.Word.Spelling == "single").FirstOrDefault();

            Assert.AreEqual(LearningSession.NextResult.ExpectedOtherVariant, actual);
            Assert.IsNotNull(currentWord);
            Assert.AreEqual(1, currentWord.TimesToShow);
            Assert.AreEqual(session.CurrentWord.Word.ID, currentWord.Word.ID);
        }
        public void NextFinished()
        {
            var session = new LearningSession(this.words, this.words, 1);
            bool isFinished = false;
            session.OnFinish += (s) => isFinished = true;

            session.CurrentWord.Answer = "one";
            session.Next();
            session.CurrentWord.Answer = "two";
            session.Next();

            session.CurrentWord.Answer = "single";
            var actual = session.Next();

            Assert.AreEqual(LearningSession.NextResult.Finished, actual);
            Assert.IsNull(session.CurrentWord);
            Assert.AreEqual(0, session.Items.Count);
            Assert.AreEqual(3, session.PassedWords.Count);
            Assert.AreEqual(true, isFinished);
        }
예제 #7
0
 public void UpdateScheduleTest(LearningSession session)
 {
     this.UpdateSchedule(session);
 }