コード例 #1
0
 public void Reset_Data_Source_Should_Clear_Flashcards()
 {
     DataStore.Instance.Flashcards = SimpleAdditionCardFactory.CreateCompleteSet(1, 2, 1, 2);
     DataStore.Instance.Flashcards.Count().ShouldNotBe(0);
     DataStore.Reset();
     DataStore.Instance.Flashcards.Count().ShouldBe(0);
 }
コード例 #2
0
 private TimedTest <SimpleAdditionCard, int> GetTimedTest()
 {
     return(new TimedTest <SimpleAdditionCard, int>
     {
         FlashCards = SimpleAdditionCardFactory.CreateCompleteSet(2, 10, 2, 10)
     });
 }
コード例 #3
0
        public void Cards_Should_Be_In_A_Random_Order()
        {
            var originalList = SimpleAdditionCardFactory.CreateCompleteSet(2, 100, 2, 100);

            var timedTest = new TimedTest <SimpleAdditionCard, int>
            {
                FlashCards = originalList
            };

            timedTest.PrepareTest();

            var randomlyOrderedCards = timedTest.PreparedCards;

            for (int i = 1; i < originalList.Count - 1; i++)
            {
                var previous = randomlyOrderedCards[i - 1].Equals(originalList[i - 1]);
                var current  = randomlyOrderedCards[i].Equals(originalList[i]);
                var next     = randomlyOrderedCards[i + 1].Equals(originalList[i + 1]);

                (previous && current && next).ShouldBe(false);
            }
        }
コード例 #4
0
        private static void Main(string[] args)
        {
            var flashcards = SimpleAdditionCardFactory.CreateCompleteSet(1, 1, 1, 9);

            DataStore.Instance.Flashcards = flashcards;
            DataStore.Instance.Save("SimpleData.json.txt");

            var test = new TimedTest <SimpleAdditionCard, int>
            {
                FlashCards = SimpleAdditionCardFactory.CreateCompleteSet(2, 10, 5, 12)
            };

            test.PrepareTest();

            for (int i = 0; i < test.FlashCards.Count; i++)
            {
                var card = test.GetNextCard();
                Console.WriteLine(card.Prompt);


                var validNumber = false;
                int number      = -1;
                while (!validNumber)
                {
                    var input = Console.ReadLine();
                    validNumber = int.TryParse(input, out number);
                }

                test.Answer(number);
            }


            Console.WriteLine("You missed: {0}", test.NumberOfIncorrectAnswers);
            Console.WriteLine();

            var wrongAnswers = (from x in test.FlashCardResults
                                where !x.IsCorrect
                                select x).ToList();

            foreach (var wrongAnswer in wrongAnswers)
            {
                Console.WriteLine(wrongAnswer.Flashcard.Prompt);
                Console.WriteLine("Your Answer:      {0}", wrongAnswer.Answer);
                Console.WriteLine("Correct Answer:   {0}", wrongAnswer.Flashcard.Answer);
                Console.WriteLine();
            }

            var averageRightAnswerTimeTicks = (from x in test.FlashCardResults
                                               where x.IsCorrect
                                               select x.Seconds).Average();

            var averageRightAnswerTime = TimeSpan.FromSeconds(averageRightAnswerTimeTicks);

            Console.WriteLine("Average Answer Time: {0}", averageRightAnswerTime);


            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Press enter to close...");
            Console.ReadLine();
        }