Exemplo n.º 1
0
 public override bool Equals(object obj)
 {
     if (obj is Node node)
     {
         return(Kind == node.Kind &&
                StringValue == node.StringValue &&
                NumberValue == node.NumberValue &&
                OperatorValue == node.OperatorValue &&
                (ReferenceValue == node.ReferenceValue || ReferenceValue.Equals(node.ReferenceValue)) &&
                (FunctionCall == node.FunctionCall || FunctionCall.Equals(node.FunctionCall)) &&
                SubSelect == node.SubSelect || SubSelect.Equals(node.SubSelect));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        public void FunctionCall_ShouldImplement_ValueEquality()
        {
            var functioncall = new FunctionCall(
                new Identifier(0, "func"),
                new List <Actual>()
            {
                new Actual(new Identifier(0, "x")),
                new Actual(new Identifier(0, "y"))
            }
                );

            Assert.That(functioncall.Equals(null), Is.False);
            Assert.That(functioncall.Equals(new Identifier(0, "func")), Is.False);
            Assert.That(functioncall.Equals(new FunctionCall(
                                                new Identifier(0, "wrong"),
                                                new List <Actual>()
            {
                new Actual(new Identifier(0, "x")),
                new Actual(new Identifier(0, "y"))
            }
                                                )), Is.False);
            Assert.That(functioncall.Equals(new FunctionCall(
                                                new Identifier(0, "func"),
                                                new List <Actual>()
            {
                new Actual(new Identifier(0, "x")),
            }
                                                )), Is.False);
            Assert.That(functioncall.Equals(new FunctionCall(
                                                new Identifier(0, "func"),
                                                new List <Actual>()
            {
                new Actual(new Identifier(0, "x")),
                new Actual(new Identifier(0, "wrong"))
            }
                                                )), Is.False);
            Assert.That(functioncall.Equals(new FunctionCall(
                                                new Identifier(0, "func"),
                                                new List <Actual>()
            {
                new Actual(new Identifier(0, "x")),
                new Actual(new Identifier(0, "y"))
            }
                                                )), Is.True);
        }