예제 #1
0
 private void FillWindow()
 {
     currentQuestions     = dictionary.GetNext();
     btn_Answer_1.Content = currentQuestions.answers[0];
     btn_Answer_2.Content = currentQuestions.answers[1];
     btn_Answer_3.Content = currentQuestions.answers[2];
     btn_Answer_4.Content = currentQuestions.answers[3];
     txbl_Question.Text   = currentQuestions.question;
 }
예제 #2
0
        public void Dictionary_IsCorrectAnswer_Returns_False()
        {
            //Arrange
            Dictionary dictionary = new Dictionary();

            //Act
            CurrentQuestion currentQuestion = new CurrentQuestion();

            currentQuestion = dictionary.GetNext();
            //Assert
            Assert.IsTrue(dictionary.IsCorrectAnswer(currentQuestion.question, currentQuestion.answers[0]));
        }
예제 #3
0
        public void Dictionary_GetNext_Returns_CurrentQuestion()
        {
            //Arrange
            Dictionary dictionary = new Dictionary();

            //Act
            CurrentQuestion currentQuestion = new CurrentQuestion();

            currentQuestion = dictionary.GetNext();
            //Assert
            Assert.IsNotNull(currentQuestion.answers);
        }
예제 #4
0
        public CurrentQuestion GetNext()
        {
            Random          rand             = new Random();
            CurrentQuestion currentQuestions = new CurrentQuestion();

            currentQuestions.answers   = new string[4];
            currentQuestions.question  = dictionary.ElementAt(rand.Next(0, dictionary.Count)).Key;
            currentQuestions.correctID = rand.Next(0, 3);
            dictionary.TryGetValue(currentQuestions.question, out currentQuestions.answers[currentQuestions.correctID]);
            for (int i = 0; i < currentQuestions.answers.Length; i++)
            {
                if (currentQuestions.answers[i] == null)
                {
                    currentQuestions.answers[i] = dictionary.ElementAt(rand.Next(0, dictionary.Count)).Value;
                }
            }
            return(currentQuestions);
        }