Esempio n. 1
0
        public void TestSucceeded1In1_NotSwitched()
        {
            int amount = 1;
            int counter = 0;
            isSwitched = false;
            // set counter to 0 for all cards
            foreach (var card in dictionary)
                card.Counter1[type] = counter;

            int countersBefore = GetCountersSum();

            Training training = new Training(dictionary, isSwitched, amount, counter + 1, type, learnedBefore);

            // provide correct answer for one card
            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 that card counter increased and number of learned cards
            int countersAfter = GetCountersSum();
            Assert.AreEqual(counter + 1, cardToLearn.Counter1[type], "Validating card counter");
            Assert.AreEqual(amount, training.CorrectAnswers, "Validating number of correct answers");
            Assert.AreEqual(amount, training.TotalCards, "Validating number of cards in training");
            Assert.AreEqual(countersBefore + training.CorrectAnswers, countersAfter, "Validating that only counter of one type for one word increased");
        }
Esempio n. 2
0
        public void TestFailedDontDecreaseCounter()
        {
            maxCards = 1;
            maxCounter = 0;

            // set counter to 0 for all cards
            foreach (var card in dictionary)
                card.Counter1[type] = maxCounter;
            int countersBefore = GetCountersSum();

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

            // provide incorrect answer
            var timeBefore = DateTime.Now;
            var cardToLearn = training.NextCard();
            var timeAfter = DateTime.Now;
            CheckLastTrained(timeBefore, timeAfter, cardToLearn.LastTrained);
            training.CheckAnswer(cardToLearn.Word1, false);
            CheckLastTrained(timeBefore, timeAfter, cardToLearn.LastTrained); // check that doesn't chaned after answer

            // check that card counter increased and number of learned cards
            int countersAfter = GetCountersSum();
            Assert.AreEqual(maxCounter, cardToLearn.Counter1[type], "Validating card counter");
            Assert.AreEqual(0, training.CorrectAnswers, "Validating number of correct answers");
            Assert.AreEqual(maxCards, training.TotalCards, "Validating number of cards in training");
            Assert.AreEqual(countersBefore, countersAfter, "Validating that none counters increased");
        }
Esempio n. 3
0
        public void TestFailedDecreaseCounterTo0()
        {
            maxCards = 1;
            maxCounter = 0;
            // set counter to 0 for all cards
            foreach (var card in dictionary)
                card.Counter1[type] = maxCounter;

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

            // increase counter from 0 to 1 for one card
            var cardToLearn = training.NextCard();
            training.CheckAnswer(cardToLearn.Word1, true);

            // check that card counter increased and number of learned cards
            Assert.AreEqual(maxCounter, cardToLearn.Counter1[type], "Validating card counter");
            Assert.AreEqual(0, training.CorrectAnswers, "Validating number of correct answers");
            Assert.AreEqual(maxCards, training.TotalCards, "Validating number of cards in training");
        }
Esempio n. 4
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);
        }