Пример #1
0
        public CompareResult Compare(Table otherTable)
        {
            // guard clause: Different table names are not comparables
            if (!Name.EqualsIgnoreCase(otherTable.Name))
                throw new InvalidOperationException("Tables are not comparables. In order to compare two tables they must have the same name.");

            CompareResult result = new CompareResult();
            foreach (Column eachColumn in _columnList)
            {
                Column otherColumn = otherTable.FindColumnByName(eachColumn.Name);
                if (otherColumn == null)
                    result.AddMissing(eachColumn);
                else
                    if (!eachColumn.Equals(otherColumn))
                    {
                        var conflict = new TableConflict(new Pair<Column>(eachColumn, otherColumn));
                        result.AddConflict(conflict);
                    }
            }
            return result;
        }