Exemple #1
0
        public void IntConstructorSingleTableReturnsSelectedQuizMultiple()
        {
            // Arrange
            const int testMultiple = 5;
            var       engine       = new MultiplicationEngine(new[] { testMultiple });
            var       p            = engine.CreateRandomMultiplicationProblem();

            // Act
            int multiple = p.Multiple;

            // Assert
            Assert.AreEqual((int)testMultiple, multiple);
            Assert.IsFalse(p.IsAnswered);
        }
Exemple #2
0
        public void IntConstructorMultipleTableReturnsSelectedQuizMultiple()
        {
            // Arrange
            int[] testMultiples = new[] { 2, 4, 8 };
            var   engine        = new MultiplicationEngine(testMultiples);
            var   p             = engine.CreateRandomMultiplicationProblem();

            // Act
            int multiple = p.Multiple;

            // Assert
            Assert.IsTrue(new List <int>(testMultiples).Contains(multiple));
            Assert.IsFalse(p.IsAnswered);
        }
Exemple #3
0
        public void IntConstructorSingleTableEvaluateReturnsTrueWhenAnswerIsCorrect()
        {
            // Arrange
            const int testMultiple = 5;
            var       engine       = new MultiplicationEngine(new[] { testMultiple });
            var       p            = engine.CreateRandomMultiplicationProblem();

            p.Answer = p.Multiple * p.Multiplier;

            // Act
            bool result = engine.Evaluate(p);

            // Assert
            Assert.IsTrue(p.IsAnswered);
            Assert.IsTrue(result);
        }
Exemple #4
0
        public void EnumConstructorSingleTableEvaluateReturnsFalseWhenAnswerIsNotCorrect()
        {
            // Arrange
            const MultiplicationTable testMultiple = MultiplicationTable.Five;
            var engine = new MultiplicationEngine(new[] { testMultiple });
            var p      = engine.CreateRandomMultiplicationProblem();

            p.Answer = 33; // just a number that is not a multiple of testMultiple

            // Act
            bool result = engine.Evaluate(p);

            // Assert
            Assert.IsTrue(p.IsAnswered);
            Assert.IsFalse(result);
        }
Exemple #5
0
        public MultiplicationProblem GetProblem()
        {
            var engine = new MultiplicationEngine((IEnumerable <int>)HttpContext.Current.Session[QuizMultiplesSessionKey]);

            return(engine.CreateRandomMultiplicationProblem());
        }