Esempio n. 1
0
        public void Solutions_DivideOperator_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(14);

            Solutions new_solutions = solutions / equation3;
            Assert.AreEqual(2, new_solutions.Count);
            Assert.AreEqual(1, new_solutions[0].Value);
            Assert.AreEqual((decimal)6/(decimal)14, new_solutions[1].Value);

            new_solutions = solutions / new Integer(3);
            Assert.AreEqual(2, new_solutions.Count);
            Assert.AreEqual((decimal)14 / (decimal)3, new_solutions[0].Value);
            Assert.AreEqual(2, new_solutions[1].Value);
        }
Esempio n. 2
0
 public void Integer_Constructor_Test()
 {
     Integer test = new Integer(7);
     Assert.AreEqual(7, test.Value);
     Assert.AreEqual("7", test.ToString());
 }