public async Task TwoWaySynchronize_DeletedLocal_WithWrongHint2(GenericConflictResolution conflictWinner) { await InitializeWithTwoEvents(); _localRepository.Delete("l1"); _localRepository.Delete("l2"); ExecuteMultipleTimes(() => { SynchronizePartialTwoWay( conflictWinner, new[] { IdWithHints.Create(new Identifier("l1"), (int?)666, null), }, CreateIdentifiers()); AssertLocalCount(0); AssertServerCount(1); AssertServer("s2", 0, "Item 2"); }); ExecuteMultipleTimes(() => { SynchronizeTwoWay(conflictWinner); AssertLocalCount(0); AssertServerCount(0); }); }
private void OnItemSavedOrDeleted(object item, bool wasDeleted) { IIdWithHints <string, DateTime> entryId = null; var appointment = item as AppointmentItem; if (appointment != null) { entryId = IdWithHints.Create(appointment.EntryID, (DateTime?)appointment.LastModificationTime, wasDeleted); } else { var task = item as TaskItem; if (task != null) { entryId = IdWithHints.Create(task.EntryID, (DateTime?)task.LastModificationTime, wasDeleted); } else { var contact = item as ContactItem; if (contact != null) { entryId = IdWithHints.Create(contact.EntryID, (DateTime?)contact.LastModificationTime, wasDeleted); } } } if (entryId != null) { OnItemSavedOrDeleted(entryId); } }
public async Task TwoWaySynchronize_ChangedLocal_VersionSpecified(GenericConflictResolution conflictWinner) { await InitializeWithTwoEvents(); _localRepository.UpdateWithoutIdChange("l1", _ => "Item 1 upd"); _localRepository.UpdateWithoutIdChange("l2", _ => "Item 2 upd"); ExecuteMultipleTimes(() => { SynchronizePartialTwoWay( conflictWinner, new[] { IdWithHints.Create(new Identifier("l1"), (int?)0, null), // Same version as knyown version specified => isn't synced IdWithHints.Create(new Identifier("l2"), (int?)999, null) // Other version as knyown version specified => is synced }, CreateIdentifiers()); AssertLocalCount(2); AssertLocal("l1", 1, "Item 1 upd"); AssertLocal("l2", 1, "Item 2 upd"); AssertServerCount(2); AssertServer("s1", 0, "Item 1"); AssertServer("s2u", 1, "Item 2 upd"); }); ExecuteMultipleTimes(() => { SynchronizeTwoWay(conflictWinner); AssertLocalCount(2); AssertLocal("l1", 1, "Item 1 upd"); AssertLocal("l2", 1, "Item 2 upd"); AssertServerCount(2); AssertServer("s1u", 1, "Item 1 upd"); AssertServer("s2u", 1, "Item 2 upd"); }); }
public async Task TwoWaySynchronize_AddedLocal_WithHint(GenericConflictResolution conflictWinner) { await _localRepository.Create(v => Task.FromResult("Item 1"), NullSynchronizationContextFactory.Instance.Create().Result); await _localRepository.Create(v => Task.FromResult("Item 2"), NullSynchronizationContextFactory.Instance.Create().Result); ExecuteMultipleTimes(() => { SynchronizePartialTwoWay( conflictWinner, new[] { IdWithHints.Create(new Identifier("l1"), (int?)0, null), }, CreateIdentifiers()); AssertLocalCount(2); AssertLocal("l1", 0, "Item 1"); AssertLocal("l2", 0, "Item 2"); AssertServerCount(1); AssertServer("s1", 0, "Item 1"); }); ExecuteMultipleTimes(() => { SynchronizeTwoWay(conflictWinner); AssertLocalCount(2); AssertLocal("l1", 0, "Item 1"); AssertLocal("l2", 0, "Item 2"); AssertServerCount(2); AssertServer("s1", 0, "Item 1"); AssertServer("s2", 0, "Item 2"); }); }
private void OnItemSavedOrDeleted(object item, ItemAction action) { IIdWithHints <string, DateTime> entryId = null; bool wasDeleted = action == ItemAction.Delete; var appointment = item as AppointmentItem; if (appointment != null) { s_logger.Debug($"'{nameof (ItemAction)}.{action}': Appointment '{appointment.Subject}' '{appointment.EntryID}' "); entryId = IdWithHints.Create(appointment.EntryID, (DateTime?)appointment.LastModificationTime, wasDeleted); } else { var task = item as TaskItem; if (task != null) { s_logger.Debug($"'{nameof (ItemAction)}.{action}': Task '{task.Subject}' '{task.EntryID}' "); entryId = IdWithHints.Create(task.EntryID, (DateTime?)task.LastModificationTime, wasDeleted); } else { var contact = item as ContactItem; if (contact != null) { s_logger.Debug($"'{nameof (ItemAction)}.{action}': Contact '{contact.LastNameAndFirstName}' '{contact.EntryID}' "); entryId = IdWithHints.Create(contact.EntryID, (DateTime?)contact.LastModificationTime, wasDeleted); } } } if (entryId != null) { OnItemSavedOrDeleted(entryId); } }
public async Task TwoWaySynchronize_AddedLocal_WithWrongHint(GenericConflictResolution conflictWinner) { await _localRepository.Create(v => Task.FromResult("Item 1"), NullSynchronizationContextFactory.Instance.Create().Result); await _localRepository.Create(v => Task.FromResult("Item 2"), NullSynchronizationContextFactory.Instance.Create().Result); ExecuteMultipleTimes(() => { SynchronizePartialTwoWay( conflictWinner, new[] { IdWithHints.Create(new Identifier("l1"), (int?)null, true), // specifying deletion hint true for a new item causes the item not to be synced }, CreateIdentifiers()); AssertLocalCount(2); AssertLocal("l1", 0, "Item 1"); AssertLocal("l2", 0, "Item 2"); AssertServerCount(0); }); ExecuteMultipleTimes(() => { SynchronizeTwoWay(conflictWinner); AssertLocalCount(2); AssertLocal("l1", 0, "Item 1"); AssertLocal("l2", 0, "Item 2"); AssertServerCount(2); AssertServer("s1", 0, "Item 1"); AssertServer("s2", 0, "Item 2"); }); }
private static IIdWithHints <Identifier, int>[] CreateIdentifiers(params string[] values) { return(values.Select(v => IdWithHints.Create(new Identifier(v), (int?)null, null)).ToArray()); }
public GenericId(string entryId, DateTime lastModificationTime, bool wasDeleted) { Inner = IdWithHints.Create(entryId, (DateTime?)lastModificationTime, wasDeleted); }
public AppointmentId(Implementation.Events.AppointmentId appointmentId, DateTime lastModificationTime, bool wasDeleted) { Inner = IdWithHints.Create(appointmentId, (DateTime?)lastModificationTime, wasDeleted); }