Beispiel #1
0
 public void Operator_ConstructorInputsMinus_CreatesOperatorTreeBasedUponInputs()
 {
     var left = new Operand(OperandEnum.x);
     var Right = new Operand(OperandEnum.three);
     var op = new Operator(OperatorEnum.subtract, left, Right);
     Assert.AreEqual(left.Type, op.Left.Type, "left type");
     Assert.AreEqual(Right.Type, op.Right.Type, "rigth type");
     Assert.AreEqual("(x-3)", op.ToString(), "to string");
     Assert.AreEqual(2, op.Evalate(5), "evaluate");
     Assert.AreEqual(false, op.DivideByZeroFlag, "divide by zero flage");
     Assert.AreEqual(2, op.Size(), "height");
     Assert.AreEqual(true, op.GetRandomNode().Type == op.Type
         || op.GetRandomNode().Type == left.Type
         || op.GetRandomNode().Type == Right.Type, "random node");
 }
Beispiel #2
0
 public void Operator_ConstructorInputsMultiply_CreatesOperatorTreeBasedUponInputs()
 {
     var left = new Operand(OperandEnum.x);
     var right = new Operand(OperandEnum.three);
     var op = new Operator(OperatorEnum.multiply, left, right);
     Assert.AreEqual(left.Type, op.Left.Type);
     Assert.AreEqual(right.Type, op.Right.Type);
     Assert.AreEqual("(x*3)", op.ToString());
     Assert.AreEqual(15, op.Evalate(5));
     Assert.AreEqual(false, op.DivideByZeroFlag);
     Assert.AreEqual(2, op.Size());
     Assert.AreEqual(true, op.GetRandomNode().Type == op.Type
         || op.GetRandomNode().Type == left.Type
         || op.GetRandomNode().Type == right.Type);
 }
Beispiel #3
0
 public void Operator_ConstructorInputsDivideWithZero_CreatesOperatorTreeBasedUponInputs()
 {
     var left = new Operand(OperandEnum.x);
     var right = new Operand(OperandEnum.zero);
     var op = new Operator(OperatorEnum.divide, left, right);
     Assert.AreEqual(left.Type, op.Left.Type, "type of left");
     Assert.AreEqual(right.Type, op.Right.Type, "type of right");
     Assert.AreEqual("(x/0)", op.ToString(), "string");
     Assert.AreEqual(double.MaxValue, op.Evalate(6), "evaluate");
     Assert.AreEqual(true, op.DivideByZeroFlag, "divide by zero flage");
     Assert.AreEqual(2, op.Size(), "height");
     //Assert.AreEqual(4, op.GetRandomNode().Type);
     Assert.AreEqual(true, (op.GetRandomNode().Type == op.Type
         || op.GetRandomNode().Type == left.Type
         || op.GetRandomNode().Type == right.Type), "random node");
 }