public void GetOperationElements_InvalidOperationString_ThrowsIncorrectOperationStringException() { var expressionTransformer = new ExpressionTransformer(); TestDelegate t = () => expressionTransformer.GetOperationElements("2!2"); Assert.Throws<IncorrectOperationStringException>(t); }
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)); }
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())); }
public Calculator(ExpressionTransformer expressionTransformer, IOnpAlgorithm onpAlgorithm) { this.expressionTransformer = expressionTransformer; this.onpAlgorithm = onpAlgorithm; }