Пример #1
0
        public void TestGroupByClauseEquals()
        {
            GroupByClause first = new GroupByClause()
            {
                Groups = new List <GroupBy.Group>()
                {
                    new ExpressionGroup()
                    {
                        Expression = new ColumnReference()
                        {
                            Identifiers = new List <string>()
                            {
                                "c1"
                            }
                        }
                    }
                }
            };

            GroupByClause firstClone = new GroupByClause()
            {
                Groups = new List <GroupBy.Group>()
                {
                    new ExpressionGroup()
                    {
                        Expression = new ColumnReference()
                        {
                            Identifiers = new List <string>()
                            {
                                "c1"
                            }
                        }
                    }
                }
            };

            GroupByClause second = new GroupByClause()
            {
                Groups = new List <GroupBy.Group>()
                {
                    new ExpressionGroup()
                    {
                        Expression = new ColumnReference()
                        {
                            Identifiers = new List <string>()
                            {
                                "c2"
                            }
                        }
                    }
                }
            };

            //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());
        }