--- a/trunk/UnitTests/SyncAppointmentsTests.cs +++ b/trunk/UnitTests/SyncAppointmentsTests.cs @@ -42,9 +42,9 @@ sync.SyncContacts = false; sync.SyncProfile = syncProfile; Assert.IsNotNull(syncAppointmentsFolder); - AppointmentsSynchronizer.SyncAppointmentsFolder = syncAppointmentsFolder; - AppointmentsSynchronizer.TimeMin = DateTime.Now.AddMonths(-1); - AppointmentsSynchronizer.TimeMax = DateTime.Now.AddMonths(1); + Synchronizer.SyncAppointmentsFolder = syncAppointmentsFolder; + Synchronizer.MonthsInPast = 1; + Synchronizer.MonthsInFuture = 1; sync.LoginToGoogle(gmailUsername); sync.LoginToOutlook(); @@ -61,13 +61,13 @@ Outlook.MAPIFolder mapiFolder = null; Outlook.Items items = null; - if (string.IsNullOrEmpty(AppointmentsSynchronizer.SyncAppointmentsFolder)) + if (string.IsNullOrEmpty(Synchronizer.SyncAppointmentsFolder)) { mapiFolder = Synchronizer.OutlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); } else { - mapiFolder = Synchronizer.OutlookNameSpace.GetFolderFromID(AppointmentsSynchronizer.SyncAppointmentsFolder); + mapiFolder = Synchronizer.OutlookNameSpace.GetFolderFromID(Synchronizer.SyncAppointmentsFolder); } Assert.NotNull(mapiFolder); @@ -102,7 +102,7 @@ Marshal.ReleaseComObject(items); } - var query = sync.appointmentsSynchronizer.EventRequest.List(AppointmentsSynchronizer.SyncAppointmentsGoogleFolder); + var query = sync.EventRequest.List(Synchronizer.SyncAppointmentsGoogleFolder); Events feed; string pageToken = null; do @@ -113,17 +113,17 @@ { if (!e.Status.Equals("cancelled") && e.Summary != null && e.Summary == name) { - sync.appointmentsSynchronizer.EventRequest.Delete(AppointmentsSynchronizer.SyncAppointmentsGoogleFolder, e.Id).Execute(); - Logger.Log("Deleted Google test appointment: " + e.Summary + " - " + AppointmentsSynchronizer.GetTime(e), EventType.Information); + sync.EventRequest.Delete(Synchronizer.SyncAppointmentsGoogleFolder, e.Id).Execute(); + Logger.Log("Deleted Google test appointment: " + e.Summary + " - " + Synchronizer.GetTime(e), EventType.Information); } } pageToken = feed.NextPageToken; } while (pageToken != null); - sync.appointmentsSynchronizer.LoadAppointments(); - Assert.AreEqual(0, sync.appointmentsSynchronizer.GoogleAppointments.Count); - Assert.AreEqual(0, sync.appointmentsSynchronizer.OutlookAppointments.Count); + sync.LoadAppointments(); + Assert.AreEqual(0, sync.GoogleAppointments.Count); + Assert.AreEqual(0, sync.OutlookAppointments.Count); } void Logger_LogUpdated(string message) @@ -144,7 +144,7 @@ sync.SyncOption = SyncOption.OutlookToGoogleOnly; // create new Outlook test appointment - var ola1 = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + var ola1 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); ola1.Subject = name; ola1.Start = DateTime.Now; ola1.End = DateTime.Now.AddHours(1); @@ -154,13 +154,13 @@ // create new Google test appointments var e1 = Factory.NewEvent(); - sync.appointmentsSynchronizer.UpdateAppointment(ola1, ref e1); + sync.UpdateAppointment(ola1, ref e1); var e2 = Factory.NewEvent(); AppointmentSync.UpdateAppointment(ola1, e2); AppointmentPropertiesUtils.SetGoogleOutlookAppointmentId(sync.SyncProfile, e2, ola1); - e2 = sync.appointmentsSynchronizer.SaveGoogleAppointment(e2); - - var gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, ola1); + e2 = sync.SaveGoogleAppointment(e2); + + var gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, ola1); var gid_e1 = AppointmentPropertiesUtils.GetGoogleId(e1); var gid_e2 = AppointmentPropertiesUtils.GetGoogleId(e2); var oid_e1 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, e1); @@ -175,17 +175,17 @@ // assert appointment ola1 does not point to e2 Assert.AreNotEqual(gid_ola1, gid_e2); - sync.appointmentsSynchronizer.LoadAppointments(); - - var f_e1 = sync.appointmentsSynchronizer.GetGoogleAppointmentById(gid_e1); - var f_e2 = sync.appointmentsSynchronizer.GetGoogleAppointmentById(gid_e2); - var f_ola1 = sync.appointmentsSynchronizer.GetOutlookAppointmentById(oid_ola1); + sync.LoadAppointments(); + + var f_e1 = sync.GetGoogleAppointmentById(gid_e1); + var f_e2 = sync.GetGoogleAppointmentById(gid_e2); + var f_ola1 = sync.GetOutlookAppointmentById(oid_ola1); Assert.IsNotNull(f_e1); Assert.IsNotNull(f_e2); Assert.IsNotNull(f_ola1); - var f_gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, f_ola1); + var f_gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, f_ola1); var f_gid_e1 = AppointmentPropertiesUtils.GetGoogleId(f_e1); var f_gid_e2 = AppointmentPropertiesUtils.GetGoogleId(f_e2); var f_oid_e1 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, f_e1); @@ -211,7 +211,7 @@ sync.SyncOption = SyncOption.OutlookToGoogleOnly; // create new Outlook test appointment - var ola1 = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + var ola1 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); ola1.Subject = name; ola1.Start = DateTime.Now; ola1.End = DateTime.Now.AddHours(1); @@ -221,14 +221,14 @@ // create new Google test appointments var e1 = Factory.NewEvent(); - sync.appointmentsSynchronizer.UpdateAppointment(ola1, ref e1); + sync.UpdateAppointment(ola1, ref e1); var e2 = Factory.NewEvent(); AppointmentSync.UpdateAppointment(ola1, e2); AppointmentPropertiesUtils.SetGoogleOutlookAppointmentId(sync.SyncProfile, e2, ola1); - e2 = sync.appointmentsSynchronizer.SaveGoogleAppointment(e2); - AppointmentPropertiesUtils.ResetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, ola1); - - var gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, ola1); + e2 = sync.SaveGoogleAppointment(e2); + AppointmentPropertiesUtils.ResetOutlookGoogleAppointmentId(sync, ola1); + + var gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, ola1); var gid_e1 = AppointmentPropertiesUtils.GetGoogleId(e1); var gid_e2 = AppointmentPropertiesUtils.GetGoogleId(e2); var oid_e1 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, e1); @@ -244,17 +244,17 @@ // assert appointment ola1 does not point to e2 Assert.AreNotEqual(gid_ola1, gid_e2); - sync.appointmentsSynchronizer.LoadAppointments(); - - var f_e1 = sync.appointmentsSynchronizer.GetGoogleAppointmentById(gid_e1); - var f_e2 = sync.appointmentsSynchronizer.GetGoogleAppointmentById(gid_e2); - var f_ola1 = sync.appointmentsSynchronizer.GetOutlookAppointmentById(oid_ola1); + sync.LoadAppointments(); + + var f_e1 = sync.GetGoogleAppointmentById(gid_e1); + var f_e2 = sync.GetGoogleAppointmentById(gid_e2); + var f_ola1 = sync.GetOutlookAppointmentById(oid_ola1); Assert.IsNotNull(f_e1); Assert.IsNotNull(f_e2); Assert.IsNotNull(f_ola1); - var f_gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, f_ola1); + var f_gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, f_ola1); var f_gid_e1 = AppointmentPropertiesUtils.GetGoogleId(f_e1); var f_gid_e2 = AppointmentPropertiesUtils.GetGoogleId(f_e2); var f_oid_e1 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, f_e1); @@ -281,7 +281,7 @@ sync.SyncOption = SyncOption.OutlookToGoogleOnly; // create new Outlook test appointment - var ola1 = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + var ola1 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); ola1.Subject = name; ola1.Start = DateTime.Now; ola1.End = DateTime.Now.AddHours(1); @@ -291,19 +291,19 @@ // create new Google test appointments var e1 = Factory.NewEvent(); - sync.appointmentsSynchronizer.UpdateAppointment(ola1, ref e1); - - var ola2 = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + sync.UpdateAppointment(ola1, ref e1); + + var ola2 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.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); - - var gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, ola1); - var gid_ola2 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync.appointmentsSynchronizer, ola2); + sync.UpdateAppointment(ola2, ref e1); + + var gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, ola1); + var gid_ola2 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, ola2); var gid_e1 = AppointmentPropertiesUtils.GetGoogleId(e1); var oid_e1 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, e1); var oid_ola1 = AppointmentPropertiesUtils.GetOutlookId(ola1); @@ -317,18 +317,18 @@ // assert appointment e1 does not point to ola1 Assert.AreNotEqual(oid_e1, oid_ola1); - 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); + sync.LoadAppointments(); + + var f_e1 = sync.GetGoogleAppointmentById(gid_e1); + var f_ola1 = sync.GetOutlookAppointmentById(oid_ola1); + var f_ola2 = sync.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_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, f_ola1); + var f_gid_ola2 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, 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); @@ -353,7 +353,7 @@ sync.SyncOption = SyncOption.OutlookToGoogleOnly; // create new Outlook test appointment - var ola1 = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + var ola1 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); ola1.Subject = name; ola1.Start = DateTime.Now; ola1.End = DateTime.Now.AddHours(1); @@ -363,21 +363,21 @@ // create new Google test appointments var e1 = Factory.NewEvent(); - sync.appointmentsSynchronizer.UpdateAppointment(ola1, ref e1); - - var ola2 = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + sync.UpdateAppointment(ola1, ref e1); + + var ola2 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.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); + sync.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); + e1 = sync.SaveGoogleAppointment(e1); + + var gid_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, ola1); + var gid_ola2 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, ola2); var gid_e1 = AppointmentPropertiesUtils.GetGoogleId(e1); var oid_e1 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, e1); var oid_ola1 = AppointmentPropertiesUtils.GetOutlookId(ola1); @@ -392,18 +392,18 @@ // 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); + sync.LoadAppointments(); + + var f_e1 = sync.GetGoogleAppointmentById(gid_e1); + var f_ola1 = sync.GetOutlookAppointmentById(oid_ola1); + var f_ola2 = sync.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_ola1 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, f_ola1); + var f_gid_ola2 = AppointmentPropertiesUtils.GetOutlookGoogleAppointmentId(sync, 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); @@ -429,7 +429,7 @@ sync.SyncOption = SyncOption.MergeOutlookWins; // create new appointment to sync - Outlook.AppointmentItem outlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + Outlook.AppointmentItem outlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); outlookAppointment.Subject = name; outlookAppointment.Start = DateTime.Now; outlookAppointment.End = DateTime.Now.AddHours(1); @@ -440,7 +440,7 @@ sync.SyncOption = SyncOption.OutlookToGoogleOnly; var googleAppointment = Factory.NewEvent(); - sync.appointmentsSynchronizer.UpdateAppointment(outlookAppointment, ref googleAppointment); + sync.UpdateAppointment(outlookAppointment, ref googleAppointment); googleAppointment = null; @@ -453,8 +453,8 @@ Assert.IsNotNull(match.GoogleAppointment); Assert.IsNotNull(match.OutlookAppointment); - Outlook.AppointmentItem recreatedOutlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); - sync.appointmentsSynchronizer.UpdateAppointment(ref match.GoogleAppointment, recreatedOutlookAppointment, match.GoogleAppointmentExceptions); + Outlook.AppointmentItem recreatedOutlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); + sync.UpdateAppointment(ref match.GoogleAppointment, recreatedOutlookAppointment, match.GoogleAppointmentExceptions); Assert.IsNotNull(outlookAppointment); Assert.IsNotNull(recreatedOutlookAppointment); // match recreatedOutlookAppointment with outlookAppointment @@ -476,7 +476,7 @@ sync.SyncOption = SyncOption.MergeOutlookWins; // create new appointment to sync - Outlook.AppointmentItem outlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + Outlook.AppointmentItem outlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); outlookAppointment.Subject = name; outlookAppointment.Start = DateTime.Now; outlookAppointment.End = DateTime.Now; @@ -487,7 +487,7 @@ sync.SyncOption = SyncOption.OutlookToGoogleOnly; var googleAppointment = Factory.NewEvent(); - sync.appointmentsSynchronizer.UpdateAppointment(outlookAppointment, ref googleAppointment); + sync.UpdateAppointment(outlookAppointment, ref googleAppointment); googleAppointment = null; @@ -500,8 +500,8 @@ Assert.IsNotNull(match.GoogleAppointment); Assert.IsNotNull(match.OutlookAppointment); - Outlook.AppointmentItem recreatedOutlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); - sync.appointmentsSynchronizer.UpdateAppointment(ref match.GoogleAppointment, recreatedOutlookAppointment, match.GoogleAppointmentExceptions); + Outlook.AppointmentItem recreatedOutlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); + sync.UpdateAppointment(ref match.GoogleAppointment, recreatedOutlookAppointment, match.GoogleAppointmentExceptions); Assert.IsNotNull(outlookAppointment); Assert.IsNotNull(recreatedOutlookAppointment); // match recreatedOutlookAppointment with outlookAppointment @@ -522,7 +522,7 @@ sync.SyncOption = SyncOption.MergeOutlookWins; // create new appointment to sync - Outlook.AppointmentItem outlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder); + Outlook.AppointmentItem outlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder); outlookAppointment.Subject = name; outlookAppointment.Start = DateTime.Now; outlookAppointment.Start = DateTime.Now; @@ -531,14 +531,14 @@ outlookAppointment.Save(); var googleAppointment = Factory.NewEvent(); - sync.appointmentsSynchronizer.UpdateAppointment(outlookAppointment, ref googleAppointment); + sync.UpdateAppointment(outlookAppointment, ref googleAppointment); Assert.AreEqual(name, googleAppointment.Summary); // read appointment from google googleAppointment = null; MatchAppointments(sync); - AppointmentsMatcher.SyncAppointments(sync.appointmentsSynchronizer); + AppointmentsMatcher.SyncAppointments(sync); AppointmentMatch match = FindMatch(outlookAppointment); @@ -582,7 +582,7 @@ { if (e != null && !e.Status.Equals("cancelled")) { - sync.appointmentsSynchronizer.EventRequest.Delete(AppointmentsSynchronizer.SyncAppointmentsGoogleFolder, e.Id); + sync.EventRequest.Delete(Synchronizer.SyncAppointmentsGoogleFolder, e.Id); Logger.Log("Deleted Google test appointment: " + e.Summary, EventType.Information); //Thread.Sleep(2000); } @@ -590,7 +590,7 @@ internal AppointmentMatch FindMatch(Outlook.AppointmentItem ola) { - foreach (AppointmentMatch match in sync.appointmentsSynchronizer.Appointments) + foreach (AppointmentMatch match in sync.Appointments) { if (match.OutlookAppointment != null && match.OutlookAppointment.EntryID == ola.EntryID) return match; @@ -601,14 +601,14 @@ private void MatchAppointments(Synchronizer sync) { //Thread.Sleep(5000); //Wait, until Appointment is really saved and available to retrieve again - sync.appointmentsSynchronizer.MatchAppointments(); + sync.MatchAppointments(); } internal AppointmentMatch FindMatch(Event e) { if (e != null) { - foreach (AppointmentMatch match in sync.appointmentsSynchronizer.Appointments) + foreach (AppointmentMatch match in sync.Appointments) { if (match.GoogleAppointment != null && match.GoogleAppointment.Id == e.Id) return match;