Beispiel #1
0
        public void GetOperationElements_InvalidOperationString_ThrowsIncorrectOperationStringException()
        {
            var expressionTransformer = new ExpressionTransformer();

            TestDelegate t = () => expressionTransformer.GetOperationElements("2!2");

            Assert.Throws <IncorrectOperationStringException>(t);
        }
Beispiel #2
0
        public void SortElementsInOnpOrder_validOperationElements_ElementsInONPQueue(string expression, IEnumerable <string> expectedValues)
        {
            var algorithm             = new OnpAlgorithm();
            var expressionTransformer = new ExpressionTransformer();

            var result = algorithm.SortElementsInOnpOrder(expressionTransformer.GetOperationElements(expression));

            Assert.AreEqual(expectedValues, result.Select(r => r.Value));
        }
Beispiel #3
0
        public void GetOperationElements_ValidOperationString_ElementsInQueue()
        {
            var expressionTransformer = new ExpressionTransformer();
            var expectation           = new OperationElementsHelper
            {
                { OperationElementType.Number, "3" },
                { OperationElementType.Operator, "+" },
                { OperationElementType.Number, "2" }
            }.Cast <OperationElement>();

            var result = expressionTransformer.GetOperationElements("3+2");

            Assert.AreEqual(expectation.Select(r => r.ToTestValue()), result.Select(r => r.ToTestValue()));
        }