public void ValuesAreReplacedInDiff() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Unpredictables>(Guid.Parse("14123F35-519B-4DB0-957C-B773BF5D3082"), Guid.Parse("BCC981FA-FE9A-4A28-87C0-469901D6683A")); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); } table1[0].TimeStamp = DateTime.Parse("2020-07-18 08:45"); table1[0].Int = 100; table1[1].TimeStamp = DateTime.Parse("2020-07-18 08:45"); table1[1].Int = 100; TakeSnapshot("Before"); table1[0].TimeStamp = DateTime.Parse("2020-09-20 09:14:42"); table1[0].Int = 101; table1[0].NullableInt = 100; table1[1].TimeStamp = DateTime.Parse("2020-09-20 19:14:42"); TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); var cols = UnpredictableColumnLocator.Locate(_om.Collection.TablesInDefinitionOrder.ToList()) .Single(t => t.Table.TableName == nameof(SnapshotObjectMother.Unpredictables)); var columnValues = UnpredictableColumnLocator.Locate(diffs.Select(td => td.TableDefinition).ToList()) .SelectMany(u => UnpredictableValueScanner.Scan(u, diffs)) .ToList(); var substitutes = columnValues .Select(uv => new SubstituteValues(uv, SubstitutionMaker.Make(uv.Values, TrackerMaker.Make(uv, _om.Collection)))) .ToList(); //Act var result = DiffValueSubstituter.Substitute(diffs, substitutes); //Assert var output = new Output(); var originalFields = diffs.Single(d => d.TableDefinition.TableName == nameof(SnapshotObjectMother.Unpredictables)) .RowDifferences.SelectMany(rd => rd.Differences.Differences); var resultFields = result.Single(d => d.TableDefinition.TableName == nameof(SnapshotObjectMother.Unpredictables)) .RowDifferences.SelectMany(rd => rd.Differences.Differences); var combined = originalFields.Zip(resultFields, (o, r) => new { o.Name, OriginalBefore = o.Before, OriginalAfter = o.After, SubstitutedBefore = r.Before, SubstitutedAfter = r.After }).OrderBy(o => o.Name); output.FormatTable(combined); output.Report.Verify(); }
public void ReferenceIdValuesAreReplacedInDiff() { var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 1)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); } TakeSnapshot("Before"); refTable1[0].Variable = "edited"; refTable1[1].Variable = "edited"; refTable1[0].ParentId = table1[3].Id; refTable1[1].ParentId = table1[4].Id; table1[0].Variable = "edited"; table1[1].Variable = "edited"; TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = DifferenceRegulator.ExpandDifferences(_om.Collection, SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after), before); var cols = UnpredictableColumnLocator.Locate(_om.Collection.TablesInDefinitionOrder.ToList()) .Single(t => t.Table.TableName == nameof(SnapshotObjectMother.Unpredictables)); var columnValues = UnpredictableColumnLocator.Locate(diffs.Select(td => td.TableDefinition).ToList()) .SelectMany(u => UnpredictableValueScanner.Scan(u, diffs)) .ToList(); var substitutes = columnValues .Select(uv => new SubstituteValues(uv, SubstitutionMaker.Make(uv.Values, TrackerMaker.Make(uv, _om.Collection)))) .ToList(); //Act var result = DiffValueSubstituter.Substitute(diffs, substitutes); //Assert var output = new Output(); var originalFields = diffs.Single(d => d.TableDefinition.TableName == nameof(SnapshotObjectMother.ReferencingTable)) .RowDifferences.SelectMany(rd => rd.Differences.Differences); var resultFields = result.Single(d => d.TableDefinition.TableName == nameof(SnapshotObjectMother.ReferencingTable)) .RowDifferences.SelectMany(rd => rd.Differences.Differences); var combined = originalFields.Zip(resultFields, (o, r) => new { o.Name, OriginalBefore = o.Before, OriginalAfter = o.After, SubstitutedBefore = r.Before, SubstitutedAfter = r.After }).OrderBy(o => o.Name); output.FormatTable(combined); output.Report.Verify(); }
public void UnpredictableValuesAreExtracted() { //Arrange var refGuids = GuidArray(3); var table1 = _om.Make <SnapshotObjectMother.GuidKeyTable>(GuidArray(4)); var refTable1 = _om.Make <SnapshotObjectMother.GuidRefTable>((refGuids[0], table1[0].GuidKeyId), (refGuids[1], table1[1].GuidKeyId)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1[0].Variable = "edited"; table1[1].Variable = "edited"; refTable1[0].Variable = "edited"; refTable1[1].Variable = "edited"; TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = DifferenceRegulator.ExpandDifferences(_om.Collection, SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after), before); var tables = diffs.Select(d => d.TableDefinition).ToList(); var unpredictableCols = UnpredictableColumnLocator.Locate(tables).Single(t => t.Table.TableName == nameof(SnapshotObjectMother.GuidKeyTable)); //Act var result = UnpredictableValueScanner.Scan(unpredictableCols, diffs); //Assert var output = new Output(); output.WrapLine($"Table {unpredictableCols.Table.TableName}"); output.WriteLine(); foreach (var valueSet in result) { output.WriteLine(); output.WrapLine($"Column {valueSet.Column.Name}"); output.WriteLine(); var values = valueSet.Values; var references = valueSet.References; var paddedRefs = references.Concat(Enumerable.Range(0, values.Count - references.Count).Select(r => (object)null)); var report = values.Zip(paddedRefs, (value, reference) => new { Value = value, Reference = reference }); output.FormatTable(report); } output.Report.Verify(); }
public void TablesNotInFirstSnapshotShouldShowAsInserts() { //Arrange var before = MakeSnapshot("Test2", 1, 0); var after = MakeSnapshot("Test", 1, 3, MakeValueSet(5), MakeValueSet(6), MakeValueSet(7)); //Act var result = SnapshotDifferenceCalculator.GetDifferences(_collection, before, after); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void MissingColumnsAreAddedToDifferences() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var table2 = _om.Make <SnapshotObjectMother.Table2>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 1)); var refTable2 = _om.Make <SnapshotObjectMother.ReferencingTable2>((1, 3), (2, 4)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); table2.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); refTable2.ToSnapshotTable(builder); } foreach (var item in table2) { item.OtherVariable = $"other {item.Id}"; } TakeSnapshot("Before"); table1[0].Variable = "edited"; table2[1].Variable = "edited"; refTable1[0].Variable = "edited"; refTable1[1].ParentId = 3; //will required table1 row with key of 3 and also 2 because that is the before refTable2[0].Variable = "edited"; refTable2[1].ParentId = 5; //will required table2 row with key of 5 but not 2 (the before) because it is edited and therefore already present TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); //Act var tableDefinition = _om.Collection.GetTableDefinition(nameof(SnapshotObjectMother.Table2)); var requiredColumns = new [] { nameof(SnapshotObjectMother.Table2.OtherVariable) }; var result = DifferenceColumnAdder.RequireColumns(_om.Collection, diffs, tableDefinition, requiredColumns, before); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void RequiredRowsThatWereInsertedAreNotRequested() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 2)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1.Add(new SnapshotObjectMother.Table { Id = 1000, Variable = "Inserted and required" }); refTable1.Add(new SnapshotObjectMother.ReferencingTable { Id = 3, OtherId = 1, OtherVariable = "Inserted", ParentId = 4, Variable = "Inserted Variable" }); refTable1.Add(new SnapshotObjectMother.ReferencingTable { Id = 4, OtherId = 2, OtherVariable = "Inserted", ParentId = 1000, Variable = "Inserted requires inserted ref" }); TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); //Act var result = ReferencedRowLocator.GetMissingRows(_om.Collection, diffs); //Assert var output = new Output(); output.WrapLine("We do not expect a request for the newly inserted row 1000"); var resultRep = result.Tables.AsReport(rep => rep.RemoveBufferLimit() .AddColumn(t => t.TableDefinition.TableName) .AddChild(t => t.Keys, trep => trep.RemoveBufferLimit() .AddColumn(c => c.ColumnName) .AddColumn(c => c.RequestedValue))); output.FormatTable(resultRep); output.Report.Verify(); }
public void UneditedReferencedRowsAreExtracted() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var table2 = _om.Make <SnapshotObjectMother.Table2>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 2)); var refTable2 = _om.Make <SnapshotObjectMother.ReferencingTable2>((1, 1), (2, 2)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); table2.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); refTable2.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1[0].Variable = "edited"; table2[1].Variable = "edited"; refTable1[0].Variable = "edited"; refTable1[1].ParentId = 3; //will required table1 row with key of 3 and also 2 because that is the before refTable2[0].Variable = "edited"; refTable2[1].ParentId = 5; //will required table2 row with key of 5 but not 2 (the before) because it is edited and therefore already present TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); //Act var result = ReferencedRowLocator.GetMissingRows(_om.Collection, diffs); //Assert var output = new Output(); var resultRep = result.Tables.AsReport(rep => rep.RemoveBufferLimit() .AddColumn(t => t.TableDefinition.TableName) .AddChild(t => t.Keys, trep => trep.RemoveBufferLimit() .AddColumn(c => c.ColumnName) .AddColumn(c => c.RequestedValue))); output.FormatTable(resultRep); output.Report.Verify(); }
public void NewRowsInParentPreservedWhenRequiringRows() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 1)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1.Add(new SnapshotObjectMother.Table { Id = 50, Variable = "Preserve this" }); table1.Add(new SnapshotObjectMother.Table { Id = 55, Variable = "Preserve this" }); refTable1[0].Variable = "Change"; refTable1.Add(new SnapshotObjectMother.ReferencingTable { Id = 30, ParentId = 4 }); refTable1.Add(new SnapshotObjectMother.ReferencingTable { Id = 40, ParentId = 55 }); TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); var rows = ReferencedRowLocator.GetMissingRows(_om.Collection, diffs); //Act var result = DifferenceEnhancer.RequireRows(_om.Collection, diffs, rows, before); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void SubstitutionsReplaceReferencedKeys() { //Arrange var refGuids = GuidArray(3); var table1 = _om.Make <SnapshotObjectMother.GuidKeyTable>(GuidArray(4)); var refTable1 = _om.Make <SnapshotObjectMother.GuidRefTable>((refGuids[0], table1[0].GuidKeyId), (refGuids[1], table1[1].GuidKeyId)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1[0].Variable = "edited"; table1[1].Variable = "edited"; refTable1[0].GuidKeyParentId = table1[1].GuidKeyId; refTable1[1].GuidKeyParentId = table1[2].GuidKeyId; TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = DifferenceRegulator.ExpandDifferences(_om.Collection, SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after), before); var tables = diffs.Select(d => d.TableDefinition).ToList(); var unpredictableCols = UnpredictableColumnLocator.Locate(tables); var columnValueSets = unpredictableCols.Select(u => UnpredictableValueScanner.Scan(u, diffs)).ToList(); //Act var result = diffs; foreach (var columnValueSet in columnValueSets) { result = ValueSubstituter.Substitute(columnValueSet, result, _om.Collection); } //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void IfThereAreNoMissingColumnsTheOriginalDiffsAreReturned() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var table2 = _om.Make <SnapshotObjectMother.Table2>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 1)); var refTable2 = _om.Make <SnapshotObjectMother.ReferencingTable2>((1, 3), (2, 4)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); table2.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); refTable2.ToSnapshotTable(builder); } foreach (var item in table2) { item.OtherVariable = $"other {item.Id}"; } TakeSnapshot("Before"); table1[0].Variable = "edited"; table2[1].Variable = "edited"; TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); //Act var tableDefinition = _om.Collection.GetTableDefinition(nameof(SnapshotObjectMother.Table2)); var requiredColumns = new [] { nameof(SnapshotObjectMother.Table2.OtherVariable) }; var result = DifferenceColumnAdder.RequireColumns(_om.Collection, diffs, tableDefinition, new List <string>(), before); //Assert var zipped = result.SelectMany(r => r.RowDifferences).Zip(diffs.SelectMany(d => d.RowDifferences)); zipped.All(z => ReferenceEquals(z.First, z.Second)) .Should().BeTrue(); }
public void RowsAreAddedToDifferences() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var table2 = _om.Make <SnapshotObjectMother.Table2>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 1)); var refTable2 = _om.Make <SnapshotObjectMother.ReferencingTable2>((1, 3), (2, 4)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); table2.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); refTable2.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1[0].Variable = "edited"; table2[1].Variable = "edited"; refTable1[0].Variable = "edited"; refTable1[1].ParentId = 3; //will required table1 row with key of 3 and also 2 because that is the before refTable2[0].Variable = "edited"; refTable2[1].ParentId = 5; //will required table2 row with key of 5 but not 2 (the before) because it is edited and therefore already present TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); var rows = ReferencedRowLocator.GetMissingRows(_om.Collection, diffs); //Act var result = DifferenceEnhancer.RequireRows(_om.Collection, diffs, rows, before); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void RowsCanBeRequiredForDeletes() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var table2 = _om.Make <SnapshotObjectMother.Table2>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 2)); var refTable2 = _om.Make <SnapshotObjectMother.ReferencingTable2>((1, 1), (2, 2)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); table2.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); refTable2.ToSnapshotTable(builder); } TakeSnapshot("Before"); refTable1.RemoveAt(1); refTable2.RemoveAt(0); TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); //Act var result = ReferencedRowLocator.GetMissingRows(_om.Collection, diffs); //Assert var output = new Output(); var resultRep = result.Tables.AsReport(rep => rep.RemoveBufferLimit() .AddColumn(t => t.TableDefinition.TableName) .AddChild(t => t.Keys, trep => trep.RemoveBufferLimit() .AddColumn(c => c.ColumnName) .AddColumn(c => c.RequestedValue))); output.FormatTable(resultRep); output.Report.Verify(); }
public void TablesWithNoReferencesArePreserved() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var table2 = _om.Make <SnapshotObjectMother.Table2>(1, 2, 3, 4, 5); var table3 = _om.Make <SnapshotObjectMother.GuidKeyTable>(Guid.Parse("D04A9F30-DEAA-4E87-B88A-C244D729BBCA")); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); table2.ToSnapshotTable(builder); table3.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1[0].Variable = "edited"; table3[0].OtherVariable = "edited"; table3.Add(new SnapshotObjectMother.GuidKeyTable() { GuidKeyId = Guid.Parse("D0E1FDD6-51E5-467C-91FD-E07BFD8D9830"), Variable = "New" }); TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); var rows = ReferencedRowLocator.GetMissingRows(_om.Collection, diffs); //Act var result = DifferenceEnhancer.RequireRows(_om.Collection, diffs, rows, before); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void IfAllReferencesArePresentAnEmptyResultIsReturned() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var table2 = _om.Make <SnapshotObjectMother.Table2>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 1)); var refTable2 = _om.Make <SnapshotObjectMother.ReferencingTable2>((1, 3), (2, 4)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); table2.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); refTable2.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1[0].Variable = "edited"; table1[1].Variable = "edited"; table2[2].Variable = "edited"; table2[3].Variable = "edited"; refTable1[0].Variable = "edited"; refTable1[1].Variable = "edited"; refTable2[0].Variable = "edited"; refTable2[1].Variable = "edited"; TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); //Act var result = ReferencedRowLocator.GetMissingRows(_om.Collection, diffs); //Assert result.Tables.Should().BeEmpty(); }
private List <SnapshotTableDifferences> MakeDifferences() { var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var table2 = _om.Make <SnapshotObjectMother.Table2>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 1)); var refTable2 = _om.Make <SnapshotObjectMother.ReferencingTable2>((1, 3), (2, 4)); var localTable = _om.Make <LocalTable>((1, 2)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); table2.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); refTable2.ToSnapshotTable(builder); localTable.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1[0].Variable = "edited"; table1[1].Variable = "edited"; table2[2].Variable = "edited"; table2[3].Variable = "edited"; refTable1[0].Variable = "edited"; refTable1[1].Variable = "edited"; refTable2[0].Variable = "edited"; refTable2[1].Variable = "edited"; localTable[0].ParentId = 1; TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); return(diffs); }
public void SubstitutionsReplaceDifferences() { //Arrange var refGuids = GuidArray(3); var table1 = _om.Make <SnapshotObjectMother.GuidKeyTable>(GuidArray(4)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); } TakeSnapshot("Before"); table1[0].Variable = "edited"; table1[1].Variable = "edited"; TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var allDiffs = SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after); var diffs = DifferenceRegulator.ExpandDifferences(_om.Collection, allDiffs, before); var tables = diffs.Select(d => d.TableDefinition).ToList(); var unpredictableCols = UnpredictableColumnLocator.Locate(tables).Single(t => t.Table.TableName == nameof(SnapshotObjectMother.GuidKeyTable)); var columnValueSets = UnpredictableValueScanner.Scan(unpredictableCols, diffs); //Act var result = ValueSubstituter.Substitute(columnValueSets, diffs, _om.Collection); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void SubstitutionCanBeDisabled() { //Arrange var table1 = _om.Make <SnapshotObjectMother.Table>(1, 2, 3, 4, 5); var refTable1 = _om.Make <SnapshotObjectMother.ReferencingTable>((1, 1), (2, 1)); void TakeSnapshot(string name) { var builder = _om.NewSnapshot(name); table1.ToSnapshotTable(builder); refTable1.ToSnapshotTable(builder); } TakeSnapshot("Before"); refTable1[0].Variable = "edited"; refTable1[1].Variable = "edited"; refTable1[0].ParentId = table1[3].Id; refTable1[1].ParentId = table1[4].Id; TakeSnapshot("After"); var before = _om.GetSnapshot("Before"); var after = _om.GetSnapshot("After"); var diffs = DifferenceRegulator.ExpandDifferences(_om.Collection, SnapshotDifferenceCalculator.GetDifferences(_om.Collection, before, after), before); var tables = diffs.Select(d => d.TableDefinition).ToList(); //Act var result = UnpredictableValueRefiner.Refine(_om.Collection, diffs, false); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }