public CompareResult Compare(SchemaSpecification otherSpec) { CompareResult result = new CompareResult(); foreach (var eachTable in _tableList) { Table otherTable = otherSpec.FindTableByName(eachTable.Name); if (otherTable == null) result.AddMissing(eachTable); else { CompareResult compareResult = eachTable.Compare(otherTable); if (compareResult.HaveValues) { var conflict = new SpecificationConflict(new Pair<Table>(eachTable, otherTable), compareResult); result.AddConflict(conflict); } } } return result; }
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; }
public void When_a_missing_column_added() { // Arrange CompareResult compareResult = new CompareResult(); compareResult.AddMissing(Column.Create("irrelevant")); // Assert Assert.That(compareResult.HaveValues, Is.True); }