예제 #1
0
        public void TestCloseNotSwitched()
        {
            isSwitched = false;
            learnedBefore = true;
            Training training = new Training(dictionary, isSwitched, maxCards, maxCounter / 2, type, learnedBefore);
            CheckTrainingList(training);

            // check that all cards are not switched in dictionary
            foreach (var card in dictionary)
                Assert.IsFalse(card.Switched);

            // check that all cards are not switched after training close
            training.Close();
            foreach (var card in dictionary)
                Assert.IsFalse(card.Switched);
        }
예제 #2
0
        public void TestSucceededSeveralInMany_Switched()
        {
            int amount = random.Next(maxCards / 2);
            isSwitched = true;
            // set counter to 0 for all cards
            foreach (var card in dictionary)
                card.Counter2[type] = 0;
            int countersBefore = GetCountersSum();

            Training training = new Training(dictionary, isSwitched, maxCards, 1, type, learnedBefore);
            CheckTrainingList(training);

            // provide correct answer for one card
            for (int i = 0; i < amount; i++)
            {
                var timeBefore = DateTime.Now;
                var cardToLearn = training.NextCard();
                var timeAfter = DateTime.Now;
                CheckLastTrained(timeBefore, timeAfter, cardToLearn.LastTrained);

                training.CheckAnswer(cardToLearn.Word2, true);
                CheckLastTrained(timeBefore, timeAfter, cardToLearn.LastTrained); // check that doesn't chaned after answer
            }

            // check number of correct answers and total cards in training
            int countersAfter = GetCountersSum();
            Assert.AreEqual(amount, training.CorrectAnswers, "Validating number of correct answers");
            Assert.AreEqual(maxCards, training.TotalCards, "Validating number of cards in training");
            Assert.AreEqual(countersBefore + training.CorrectAnswers, countersAfter, "Validating that corrent number of counters increased");
            training.Close();

            // check that training set decreased by learned cards
            training = new Training(dictionary, isSwitched, maxCards, 1, type, learnedBefore);
            int expected = maxCards - amount;
            Assert.AreEqual(expected, training.TotalCards, "Validating number of words to learn");
            CheckTrainingList(training);
        }