public void Solutions_MinusOperator_Test() { //Try to represent the equation ((5+1) x 3) - 4 IEquation node1 = new AddOperation(new Integer(5), new Integer(1)); IEquation node2 = new MultiplyOperation(node1, new Integer(3)); IEquation equation1 = new MinusOperation(node2, new Integer(4)); //Try to represent the equation 1 + 2 +3 IEquation node3 = new AddOperation(new Integer(1), new Integer(2)); IEquation equation2 = new AddOperation(node3, new Integer(3)); Solutions solutions = new Solutions(); solutions.Add(equation1); solutions.Add(equation2); IEquation equation3 = new Integer(4); Solutions new_solutions = solutions - equation3; Assert.AreEqual(2, new_solutions.Count); Assert.AreEqual(10, new_solutions[0].Value); Assert.AreEqual(2, new_solutions[1].Value); new_solutions = equation3 - solutions; Assert.AreEqual(2, new_solutions.Count); Assert.AreEqual(-10, new_solutions[0].Value); Assert.AreEqual(-2, new_solutions[1].Value); }
public void Equation_Test1() { //Try to represent the equation ((5+1) x 3) - 4 IEquation node1 = new AddOperation(new Integer(5), new Integer(1)); Assert.AreEqual(6, node1.Value); MultiplyOperation node2 = new MultiplyOperation(node1, new Integer(3)); Assert.AreEqual(18, node2.Value); MinusOperation equation = new MinusOperation(node2, new Integer(4)); Assert.AreEqual(14, equation.Value); Assert.AreEqual("((5 + 1) x 3) - 4", equation.ToString()); }
public void MinusOperation_Test() { MinusOperation op = new MinusOperation(new Integer(2), new Integer(4)); Assert.AreEqual(-2, op.Value); Assert.AreEqual("2 - 4", op.ToString()); }