public void Sync_WhenItemRemoved_ShouldCallRemoveInTheCurrentList() { var removedItem = CreateMockRecord(); _recordsComparer.Compare(Arg.Any <IEnumerable <IMockRecord> >(), Arg.Any <IEnumerable <IMockRecord> >()) .Returns(Deleted(removedItem)); _recordsSynchronizer.Sync(_currentRecords, _newRecords); _currentRecords.Received().Remove(removedItem); }
public void Compare_NoItemAdded_InsertedShouldBeEmpty() { var oldRecords = OldRecords(new MockRecord(1, "a", "florin", "iacob")); var differences = _recordsComparer.Compare(oldRecords, NewRecords()); Assert.AreEqual(0, differences.Inserted.Count()); }
public void Sync(IList <TRecord> currentRecords, IEnumerable <TRecord> newRecords) { var differences = _recordsComparer.Compare(currentRecords, newRecords); foreach (var deleted in differences.Deleted) { currentRecords.Remove(deleted); } foreach (var updated in differences.Updated) { UpdateRecord(updated.OldRecord, updated.NewRecord); } foreach (var inserted in differences.Inserted) { currentRecords.Add(inserted); } }