public void UpdateMemoTest() { _modified.Records[2]["OPIS"] = _modified.CreateMemoEntry("This is new memo entry!"); var diff = new DbfDiff(_original, _modified); Assert.IsTrue(diff.Updated.Count == 1); Assert.IsTrue(diff.Updated.ContainsKey(2)); }
public void ApplyTo(Dbf dbf) { foreach (var record in Inserted) { dbf.Records.Add(record); } foreach (int index in Deleted) { dbf.DeleteRecord(index); } foreach (var kvp in Updated) { dbf.Records[kvp.Key] = kvp.Value; if (dbf.Fields.Any(f => f.Type == DbfFieldType.Memo)) { foreach (var field in dbf.Fields) { if (field.Type != DbfFieldType.Memo) { continue; } var memoEntry = kvp.Value[field.Name] as DbfMemoEntry; if (!dbf.Memo.ContainsEntry(memoEntry)) { // this is a new memo kvp.Value[field.Name] = dbf.CreateMemoEntry(memoEntry.Value); } } } } Inserted.Clear(); Updated.Clear(); Deleted.Clear(); }