コード例 #1
0
        public void GetOperationElements_InvalidOperationString_ThrowsIncorrectOperationStringException()
        {
            var expressionTransformer = new ExpressionTransformer();

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

            Assert.Throws<IncorrectOperationStringException>(t);
        }
コード例 #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));
        }
コード例 #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()));
        }
コード例 #4
0
ファイル: Calculator.cs プロジェクト: Andegawen/Calculator
 public Calculator(ExpressionTransformer expressionTransformer, IOnpAlgorithm onpAlgorithm)
 {
     this.expressionTransformer = expressionTransformer;
     this.onpAlgorithm = onpAlgorithm;
 }