public void ShouldSynchronizeStatus() { using (Mocks.Record()) { SetupResult.For(_masterStub.GetAll()).Return(new[] { Entry("1", "/done") }); Expect.Call(_slaveMock.GetAll()).Return(new[] { Entry("1", "Development") }); _slaveMock.UpdateStatus(Entry("1", "Done")); } using (Mocks.Playback()) { _synchronizer.Synchronize(); } }
public void Synchronize() { var masterEntries = _master.GetAll().ToDictionary(e => e.Id); var slaveEntries = _slave.GetAll().ToDictionary(e => e.Id); foreach (var masterId in masterEntries.Keys) { if (slaveEntries.ContainsKey(masterId)) { SynchronizationEntry masterMappedSlaveEntry; if (!TryGetMasterEntry(slaveEntries[masterId], out masterMappedSlaveEntry)) { continue; } if (masterMappedSlaveEntry.Status == masterEntries[masterId].Status) { continue; } if (masterMappedSlaveEntry.TimeStamp.HasValue && masterEntries[masterId].TimeStamp.HasValue && masterMappedSlaveEntry.TimeStamp > masterEntries[masterId].TimeStamp) { continue; } SynchronizationEntry slaveMappedMasterEntry; if (!TryGetSlaveEntry(masterEntries[masterId], out slaveMappedMasterEntry)) { continue; } if (slaveMappedMasterEntry.Status != slaveEntries[masterId].Status) { Console.WriteLine("Status differ: {0}-{1}", slaveMappedMasterEntry, slaveEntries[masterId]); _slave.UpdateStatus(slaveMappedMasterEntry); } } } }