Example #1
0
        public void IsValidate_Equations_ReturnIsValid()
        {
            // arrange
            Dictionary <string, bool> equations = new Dictionary <string, bool>
            {
                { "42 + 18 / ( 6 + 12 / 4 )", true },
                { "12/6+10-( 5*(6+ 2))+ 27", true },
                { "( 1*2 )/( 12/6 )", true },
                { "(100 /5 +6 * 2+ (44- 22/ 10))+ (84* 56/(12/ 6 )+90-(5*5-1) )", true },
                { "5 * 4) *65", false },
                { "( 4 - 1 ) * 2x", false },
                { "10 + -6", true },
                { "10+-6", true },
                { "-10 + 6", true },
                { "-10+-9*-8/-4*60-90/-2*(-4 /2)+(55+-9*-6)+-100", true }
            };

            foreach (var equation in equations)
            {
                // act
                bool actualValid = arithmeticValidation.IsValidate(equation.Key);

                // assert
                Assert.AreEqual(equation.Value, actualValid);
            }
        }