Exemple #1
0
 public void OperationToElements_validOperationString_ElementsInQueue()
 {
     var calc = new Calculator();
     var result = calc.OperationToElements("3+2");
     var expectation = new Queue<OperationElement>();
     expectation.Enqueue(new OperationElement(OperationElementType.NUMBER,"3"));
     expectation.Enqueue(new OperationElement(OperationElementType.OPERATOR, "+"));
     expectation.Enqueue(new OperationElement(OperationElementType.NUMBER, "2"));
     Assert.AreEqual(expectation.Select(r => r.ToTestValue()), result.Select(r => r.ToTestValue()));
 }
Exemple #2
0
 public void OperationElementsToONP_validOperationElements_ElementsInONPQueue2() 
 {
     var calc = new Calculator();
     var operationElements = new Queue<OperationElement>();
     operationElements = calc.OperationToElements("2+3*5");
     var expectation = new Queue<OperationElement>();
     expectation.Enqueue(new OperationElement(OperationElementType.NUMBER, "2"));
     expectation.Enqueue(new OperationElement(OperationElementType.NUMBER, "3"));
     expectation.Enqueue(new OperationElement(OperationElementType.NUMBER, "5"));
     expectation.Enqueue(new OperationElement(OperationElementType.OPERATOR, "*"));
     expectation.Enqueue(new OperationElement(OperationElementType.OPERATOR, "+"));
     var result = calc.OperationElementsToONP(operationElements);
     Assert.AreEqual(expectation.Select(r => r.ToTestValue()), result.Select(r => r.ToTestValue()));
 }
Exemple #3
0
 public void OperationToElements_invalidOperationString_ThrowsIncorrectOperationStringException()
 {
     var calc = new Calculator();
     Assert.Throws<IncorrectOperationStringException>(() => calc.OperationToElements("2!2"));
 }