public void TestExtendedProps() { sync.SyncOption = SyncOption.MergeOutlookWins; // create new appointment to sync Outlook.AppointmentItem outlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); outlookAppointment.Subject = name; outlookAppointment.Start = DateTime.Now; outlookAppointment.Start = DateTime.Now; outlookAppointment.AllDayEvent = true; outlookAppointment.Save(); var googleAppointment = Factory.NewEvent(); sync.appointmentsSynchronizer.UpdateAppointment(outlookAppointment, ref googleAppointment); Assert.AreEqual(name, googleAppointment.Summary); // read appointment from google googleAppointment = null; MatchAppointments(sync); AppointmentsMatcher.SyncAppointments(sync.appointmentsSynchronizer); AppointmentMatch match = FindMatch(outlookAppointment); Assert.IsNotNull(match); Assert.IsNotNull(match.GoogleAppointment); // get extended prop Assert.AreEqual(AppointmentPropertiesUtils.GetOutlookId(outlookAppointment), AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, match.GoogleAppointment)); DeleteTestAppointments(match); }
private static void SyncAppointmentNoOutlook(AppointmentMatch match, AppointmentsSynchronizer sync) { string outlookAppointmenttId = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, match.GoogleAppointment); if (!string.IsNullOrEmpty(outlookAppointmenttId)) { if (sync.SyncOption == SyncOption.GoogleToOutlookOnly || !sync.SyncDelete) { return; } else if (!sync.PromptDelete) { sync.DeleteGoogleResolution = DeleteResolution.DeleteGoogleAlways; } else if (sync.DeleteGoogleResolution != DeleteResolution.DeleteGoogleAlways && sync.DeleteGoogleResolution != DeleteResolution.KeepGoogleAlways) { using (var r = new ConflictResolver()) { sync.DeleteGoogleResolution = r.ResolveDelete(match.GoogleAppointment); } } switch (sync.DeleteGoogleResolution) { case DeleteResolution.KeepGoogle: case DeleteResolution.KeepGoogleAlways: AppointmentPropertiesUtils.ResetGoogleOutlookAppointmentId(sync.SyncProfile, match.GoogleAppointment); break; case DeleteResolution.DeleteGoogle: case DeleteResolution.DeleteGoogleAlways: //Avoid recreating a OutlookAppointment already existing //==> Delete this e instead if previous match existed but no match exists anymore return; default: throw new ApplicationException("Cancelled"); } } if (sync.SyncOption == SyncOption.OutlookToGoogleOnly) { sync.SkippedCount++; Logger.Log(string.Format("Google appointment not added to Outlook, because of SyncOption " + sync.SyncOption.ToString() + ": {0}", match.GoogleAppointment.Summary), EventType.Information); return; } //create a Outlook appointment from Google appointment match.OutlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); sync.UpdateAppointment(ref match.GoogleAppointment, match.OutlookAppointment, match.GoogleAppointmentExceptions); }
public void TestSync_Time() { sync.SyncOption = SyncOption.MergeOutlookWins; // create new appointment to sync Outlook.AppointmentItem outlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); outlookAppointment.Subject = name; outlookAppointment.Start = DateTime.Now; outlookAppointment.End = DateTime.Now.AddHours(1); outlookAppointment.AllDayEvent = false; outlookAppointment.Save(); sync.SyncOption = SyncOption.OutlookToGoogleOnly; var googleAppointment = Factory.NewEvent(); sync.appointmentsSynchronizer.UpdateAppointment(outlookAppointment, ref googleAppointment); googleAppointment = null; sync.SyncOption = SyncOption.GoogleToOutlookOnly; //load the same appointment from google. MatchAppointments(sync); AppointmentMatch match = FindMatch(outlookAppointment); Assert.IsNotNull(match); Assert.IsNotNull(match.GoogleAppointment); Assert.IsNotNull(match.OutlookAppointment); Outlook.AppointmentItem recreatedOutlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); sync.appointmentsSynchronizer.UpdateAppointment(ref match.GoogleAppointment, recreatedOutlookAppointment, match.GoogleAppointmentExceptions); Assert.IsNotNull(outlookAppointment); Assert.IsNotNull(recreatedOutlookAppointment); // match recreatedOutlookAppointment with outlookAppointment Assert.AreEqual(outlookAppointment.Subject, recreatedOutlookAppointment.Subject); Assert.AreEqual(outlookAppointment.Start, recreatedOutlookAppointment.Start); Assert.AreEqual(outlookAppointment.End, recreatedOutlookAppointment.End); Assert.AreEqual(outlookAppointment.AllDayEvent, recreatedOutlookAppointment.AllDayEvent); //ToDo: Check other properties DeleteTestAppointments(match); recreatedOutlookAppointment.Delete(); }
public void TestRemoveOutlookDuplicatedAppointments_02() { sync.SyncOption = SyncOption.OutlookToGoogleOnly; // create new Outlook test appointment var ola1 = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); ola1.Subject = name; ola1.Start = DateTime.Now; ola1.End = DateTime.Now.AddHours(1); ola1.AllDayEvent = false; ola1.ReminderSet = false; ola1.Save(); // create new Google test appointments var e1 = Factory.NewEvent(); sync.appointmentsSynchronizer.UpdateAppointment(ola1, ref e1); var ola2 = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); ola2.Subject = name; ola2.Start = DateTime.Now; ola2.End = DateTime.Now.AddHours(1); ola2.AllDayEvent = false; ola2.ReminderSet = false; ola2.Save(); sync.appointmentsSynchronizer.UpdateAppointment(ola2, ref e1); AppointmentPropertiesUtils.ResetGoogleOutlookAppointmentId(sync.SyncProfile, e1); e1 = sync.appointmentsSynchronizer.SaveGoogleAppointment(e1); var gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, ola1); var gid_ola2 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, ola2); var gid_e1 = AppointmentPropertiesUtils.GetGoogleId(e1); var oid_e1 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, e1); var oid_ola1 = AppointmentPropertiesUtils.GetOutlookId(ola1); var oid_ola2 = AppointmentPropertiesUtils.GetOutlookId(ola2); // assert ola1 points to e1 Assert.AreEqual(gid_ola1, gid_e1); // assert ola2 points to e1 Assert.AreEqual(gid_ola2, gid_e1); // assert appointment e1 does not point to ola1 Assert.AreNotEqual(oid_e1, oid_ola1); // assert appointment e1 does not point to ola2 Assert.AreNotEqual(oid_e1, oid_ola2); sync.appointmentsSynchronizer.LoadAppointments(); var f_e1 = sync.appointmentsSynchronizer.GetGoogleAppointmentById(gid_e1); var f_ola1 = sync.appointmentsSynchronizer.GetOutlookAppointmentById(oid_ola1); var f_ola2 = sync.appointmentsSynchronizer.GetOutlookAppointmentById(oid_ola2); Assert.IsNotNull(f_e1); Assert.IsNotNull(f_ola1); Assert.IsNotNull(f_ola2); var f_gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, f_ola1); var f_gid_ola2 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, f_ola2); var f_gid_e1 = AppointmentPropertiesUtils.GetGoogleId(f_e1); var f_oid_e1 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, f_e1); var f_oid_ola1 = AppointmentPropertiesUtils.GetOutlookId(f_ola1); var f_oid_ola2 = AppointmentPropertiesUtils.GetOutlookId(f_ola2); // assert ola1 does not point to e1 Assert.AreNotEqual(f_gid_ola1, f_gid_e1); // assert ola2 does not point to e1 Assert.AreNotEqual(f_gid_ola2, f_gid_e1); // assert appointment e1 does not point to ola1 Assert.AreNotEqual(f_oid_e1, f_oid_ola1); // assert appointment e1 does not point to ola2 Assert.AreNotEqual(f_oid_e1, f_oid_ola2); DeleteTestAppointment(f_ola1); DeleteTestAppointment(f_ola2); DeleteTestAppointment(f_e1); }