public void DefaultValues() { var sut = new BinaryExpression(); Assert.AreEqual(BinaryOperator.Unknown, sut.Operator); Assert.AreEqual(new UnknownExpression(), sut.LeftOperand); Assert.AreEqual(new UnknownExpression(), sut.RightOperand); Assert.AreNotEqual(0, sut.GetHashCode()); Assert.AreNotEqual(1, sut.GetHashCode()); }
public void Equality_Default() { var a = new BinaryExpression(); var b = new BinaryExpression(); Assert.AreEqual(a, b); Assert.AreEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DifferentOp() { var a = new BinaryExpression { Operator = BinaryOperator.And }; var b = new BinaryExpression(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DifferentLeft() { var a = new BinaryExpression { LeftOperand = new ConstantValueExpression() }; var b = new BinaryExpression(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DifferentRight() { var a = new BinaryExpression { RightOperand = new ReferenceExpression() }; var b = new BinaryExpression(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_ReallyTheSame() { var a = new BinaryExpression { LeftOperand = new ConstantValueExpression(), Operator = BinaryOperator.And, RightOperand = new ReferenceExpression() }; var b = new BinaryExpression { LeftOperand = new ConstantValueExpression(), Operator = BinaryOperator.And, RightOperand = new ReferenceExpression() }; Assert.AreEqual(a, b); Assert.AreEqual(a.GetHashCode(), b.GetHashCode()); }
public void TestBinaryExpressionEquals() { BinaryExpression first = new BinaryExpression() { Type = BinaryType.Add, Left = new ColumnReference() { Identifiers = new List <string>() { "c1" } }, Right = new IntegerLiteral() { Value = 3 } }; BinaryExpression firstClone = new BinaryExpression() { Type = BinaryType.Add, Left = new ColumnReference() { Identifiers = new List <string>() { "c1" } }, Right = new IntegerLiteral() { Value = 3 } }; BinaryExpression second = new BinaryExpression() { Type = BinaryType.Divide, Left = new ColumnReference() { Identifiers = new List <string>() { "c1" } }, Right = new IntegerLiteral() { Value = 3 } }; BinaryExpression third = new BinaryExpression() { Type = BinaryType.Add, Left = new ColumnReference() { Identifiers = new List <string>() { "c2" } }, Right = new IntegerLiteral() { Value = 3 } }; BinaryExpression fourth = new BinaryExpression() { Type = BinaryType.Add, Left = new ColumnReference() { Identifiers = new List <string>() { "c1" } }, Right = new IntegerLiteral() { Value = 17 } }; //Equals Assert.IsTrue(Equals(first, firstClone)); Assert.IsFalse(Equals(first, null)); Assert.IsFalse(Equals(first, second)); Assert.IsFalse(Equals(first, third)); Assert.IsFalse(Equals(first, fourth)); Assert.IsFalse(Equals(first, "other type")); //Hash code Assert.AreEqual(first.GetHashCode(), firstClone.GetHashCode()); Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); Assert.AreNotEqual(first.GetHashCode(), third.GetHashCode()); Assert.AreNotEqual(first.GetHashCode(), fourth.GetHashCode()); }