Ejemplo n.º 1
0
        public void ShouldResultInLogicalOutcome01()
        {
            // For
            string operation      = "6-3*2/2-3";
            double expectedResult = 0;

            // Given
            ArithmeticLogicEngine arithmeticLogicEngine = new ArithmeticLogicEngine();
            double result = arithmeticLogicEngine.ExecuteOperation(operation);

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
Ejemplo n.º 2
0
        public void ShouldResultInLogicalOutcome05()
        {
            // For
            string operation      = "5*(10-4/2+(100*5-50/5)+15*2)-31";
            double expectedResult = 2609;

            // Given
            ArithmeticLogicEngine arithmeticLogicEngine = new ArithmeticLogicEngine();
            double result = arithmeticLogicEngine.ExecuteOperation(operation);

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
        public void ShouldLeaveDigitsAndArithmeticSigns()
        {
            // For
            List <string> expectedResult = new List <string>()
            {
                "2", "+", "10", "-", "300"
            };
            string operation = "2gi+;10-A|30p0^@]";

            // Given
            ArithmeticLogicEngine arithmeticLogicEngine = new ArithmeticLogicEngine();
            List <string>         result = arithmeticLogicEngine.ChangeToOperands(operation);

            // Assert
            CollectionAssert.AreEqual(expectedResult, result);
        }