public void KeysAreSortable() { //Arrange var td = new TestData(); td.Definer.PrimaryKey(IdCol).PrimaryKey(NameCol); for (var n = 1; n <= 10; n++) { if (n > 1) { td.NewRow(); } td.RowFields[IdCol] = n; td.RowFields[NameCol] = $"Name {n}"; td.RowFields["Details"] = $"Row details {n}"; } var rowIndex = SnapshotKeyExtractor.GetKeys(td.Snapshot, td.Table); var keys = rowIndex.Keys.ToList(); keys.Reverse(); //The keys are now out of order //Act keys.Sort(); //Restore order //Assert var output = new Output(); var rep = keys.MakeKeyReport(); output.FormatTable(rep); output.Report.Verify(); }
public void CompoundKeyTableKeysAreExtracted() { //Act var keys = SnapshotKeyExtractor.GetKeys(_snapshot, _collection.GetTableDefinition(CompoundKeyTableName)); //Assert var output = new Output(); var rep = keys.MakeKeyReport(); output.FormatTable(rep); output.Report.Verify(); }
public void ComparisonCanIdentifyEqualKeys() { //Arrange var td = new TestData(); td.Definer.PrimaryKey(IdCol).PrimaryKey(NameCol); for (var n = 1; n <= 10; n++) { if (n > 1) { td.NewRow(); } td.RowFields[IdCol] = n; td.RowFields[NameCol] = $"Name {n}"; td.RowFields["Details"] = $"Row details {n}"; } var keys = SnapshotKeyExtractor.GetKeys(td.Snapshot, td.Table).Keys; //Act/Assert keys.Select(k => ReferenceEquals(k, keys.Single(other => other.CompareTo(k) == 0))).Should().AllBeEquivalentTo(true); //Checks that for every key there is only one match in the set and the match is itself }