Example #1
0
        public void DecimalOperatorPowerMinus4IsCreatedAsExpected()
        {
            // Arrange
            var engine = new DecimalEngine(DecimalOperator.TenThousandths, DecimalOperator.TenThousandths);
            var p      = engine.CreateRandomDecimalProblem();

            // Act

            // Assert
            Assert.AreEqual(0.0001, p.Operator);
        }
Example #2
0
        public void DecimalOperatorPower1IsCreatedAsExpected()
        {
            // Arrange
            var engine = new DecimalEngine(DecimalOperator.Tens, DecimalOperator.Tens);
            var p      = engine.CreateRandomDecimalProblem();

            // Act

            // Assert
            Assert.AreEqual(10, p.Operator);
        }
Example #3
0
        public void EvaluateReturnsTrueIfAnswerCorrect()
        {
            // Arrange
            var engine         = new DecimalEngine();
            var p              = engine.CreateRandomDecimalProblem();
            var expectedAnswer = p.ProblemOperation == Operation.Multiply ? p.Number * p.Operator : p.Number / p.Operator;

            // Act
            p.Answer = Math.Round(expectedAnswer, p.GetExpectedDecimalPlacesInAnswer());

            // Assert
            Assert.IsTrue(engine.Evaluate(p));
        }
Example #4
0
        public void EvaluateReturnsFalseIfAnswerNotCorrect()
        {
            // Arrange
            var engine         = new DecimalEngine();
            var p              = engine.CreateRandomDecimalProblem();
            var expectedAnswer = p.ProblemOperation == Operation.Multiply ? p.Number * p.Operator : p.Number / p.Operator;

            // Act
            p.Answer = Math.Round(expectedAnswer + 1, 5);             // Just to make it incorrect

            // Assert
            Assert.IsFalse(engine.Evaluate(p));
        }