示例#1
0
        public void TestStatementListEquals()
        {
            StatementList first = new StatementList()
            {
                Statements = new List <Statement>()
                {
                    new SetVariableStatement()
                    {
                        ScalarExpression = new StringLiteral()
                        {
                            Value = "t"
                        }
                    }
                }
            };

            StatementList firstClone = new StatementList()
            {
                Statements = new List <Statement>()
                {
                    new SetVariableStatement()
                    {
                        ScalarExpression = new StringLiteral()
                        {
                            Value = "t"
                        }
                    }
                }
            };

            StatementList second = new StatementList()
            {
                Statements = new List <Statement>()
                {
                    new SetVariableStatement()
                    {
                        ScalarExpression = new StringLiteral()
                        {
                            Value = "t2"
                        }
                    }
                }
            };

            //Equals
            Assert.IsTrue(Equals(first, firstClone));
            Assert.IsFalse(Equals(first, null));
            Assert.IsFalse(Equals(first, second));
            Assert.IsFalse(Equals(first, "other type"));

            //Hash code
            Assert.AreEqual(first.GetHashCode(), firstClone.GetHashCode());
            Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
        }