public void QuestionGeneratorTests_Division(int operatorIndex, int min, int max, int expectedQuestionCount)
        {
            //Arrange
            var configMock = Helper.SetupConfigMock(operatorIndex, min, max);

            //Act
            var questionGenerator = new QuestionGenerator(new RandomNumberGenerator(), configMock.Object);
            int poolSize          = (max - min + 1) * (max - min + 1);

            HashSet <string> questions = new HashSet <string>();

            int count        = 0;
            int divideByZero = 0;

            while (count < poolSize)
            {
                var question = questionGenerator.GenerateQuestion();
                ++count;

                var denominator = question.Pair.Number2;
                if (denominator == 0)
                {
                    ++divideByZero;
                }

                questions.Add(question.ToString());
            }

            //Assert
            Assert.Equal(expectedQuestionCount, questions.Count);
            Assert.Equal(0, divideByZero);
        }
        public void QuestionGeneratorTests_PlusMinusMultiplication(int operatorIndex, int min, int max)
        {
            //Arrange

            Mock <IGameSetting> configMock = Helper.SetupConfigMock(operatorIndex, min, max);

            //Act
            var questionGenerator      = new QuestionGenerator(new RandomNumberGenerator(), configMock.Object);
            int expectedQuestionCount  = (max - min + 1) * (max - min + 1);
            HashSet <string> questions = new HashSet <string>();
            int count = 0;

            while (count++ < expectedQuestionCount)
            {
                questions.Add(questionGenerator.GenerateQuestion().ToString());
            }

            //Assert
            Assert.Equal(expectedQuestionCount, questions.Count);
        }
Esempio n. 3
0
 private void NextQuestion()
 {
     _currentQuestion = _generator.GenerateQuestion(_locations, _charactersLocations);
     RaisePropertyChanged(nameof(CurrentQuestionLabel));
     RaisePropertyChanged(nameof(CorrectAnswersLabel));
 }
Esempio n. 4
0
 public int StartQuestion(List <int> digits)
 {
     return(questiongenerator_script.GenerateQuestion(digits));
 }