Exemple #1
0
 public void WhenCalculationUsedInACalcualtedQuestion_ParsesCorrectly(
     string validText,
     IEnumerable <decimal> expectedLiterals,
     IEnumerable <string> expectedVariables,
     MathOperatorCount operatorCount)
 {
     CreateForm(validText);
     ValidateVariableNames(expectedVariables);
     ValidateMathLiterals(expectedLiterals);
     ValidateMathOperators(operatorCount);
 }
Exemple #2
0
        private static TestCaseData MathTestCaseData(
            string formText,
            IEnumerable <decimal> values   = null,
            IEnumerable <string> variables = null,
            MathOperatorCount operators    = new MathOperatorCount())
        {
            values    = values ?? new List <decimal>();
            variables = variables ?? new List <string>();

            return(new TestCaseData(
                       formText,
                       values,
                       variables,
                       operators));
        }
Exemple #3
0
        private void ValidateMathOperators(MathOperatorCount operatorCount)
        {
            Assert.AreEqual(
                expected: operatorCount.AdditionCount,
                actual: NodeCount <IAddNode>(),
                message: "incorrect number of addition operations");

            Assert.AreEqual(
                expected: operatorCount.SubtractionCount,
                actual: NodeCount <ISubtractNode>(),
                message: "incorrect number of subtraction operations");

            Assert.AreEqual(
                expected: operatorCount.MultiplicationCount,
                actual: NodeCount <IMultiplyNode>(),
                message: "incorrect number of multiplication operations");

            Assert.AreEqual(
                expected: operatorCount.DivisionCount,
                actual: NodeCount <IDivideNode>(),
                message: "incorrect number of division operations");
        }