Menu

[r891]: / trunk / UnitTests / SyncAppointmentsTests.cs  Maximize  Restore  History

Download this file

563 lines (465 with data), 24.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
using System;
using Google.Apis.Calendar.v3.Data;
using NUnit.Framework;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace GoContactSyncMod.UnitTests
{
[TestFixture]
public class SyncAppointmentsTests
{
private Synchronizer sync;
private static Logger.LogUpdatedHandler _logUpdateHandler = null;
//Constants for test appointment
private const string name = "AN_OUTLOOK_TEST_APPOINTMENT";
//readonly When whenDay = new When(DateTime.Now, DateTime.Now, true);
//readonly When whenTime = new When(DateTime.Now, DateTime.Now.AddHours(1), false);
//ToDo:const string groupName = "A TEST GROUP";
[OneTimeSetUp]
public void Init()
{
//string timestamp = DateTime.Now.Ticks.ToString();
if (_logUpdateHandler == null)
{
_logUpdateHandler = new Logger.LogUpdatedHandler(Logger_LogUpdated);
Logger.LogUpdated += _logUpdateHandler;
}
GoogleAPITests.LoadSettings(out var gmailUsername, out var syncProfile, out var syncContactsFolder, out var syncAppointmentsFolder);
sync = new Synchronizer
{
SyncAppointments = true,
SyncContacts = false,
SyncProfile = syncProfile
};
Assert.IsNotNull(syncAppointmentsFolder);
Synchronizer.SyncAppointmentsFolder = syncAppointmentsFolder;
Synchronizer.MonthsInPast = 1;
Synchronizer.MonthsInFuture = 1;
sync.LoginToGoogle(gmailUsername);
sync.LoginToOutlook();
}
[SetUp]
public void SetUp()
{
DeleteTestAppointments();
}
private void DeleteTestAppointments()
{
sync.LoadAppointments();
var outlookAppointment = sync.OutlookAppointments.Find("[Subject] = '" + name + "'") as Outlook.AppointmentItem;
while (outlookAppointment != null)
{
DeleteTestAppointment(outlookAppointment);
outlookAppointment = sync.OutlookAppointments.Find("[Subject] = '" + name + "'") as Outlook.AppointmentItem;
}
foreach (var googleAppointment in sync.GoogleAppointments)
{
if (googleAppointment != null &&
googleAppointment.Summary != null &&
googleAppointment.Summary == name)
{
DeleteTestAppointment(googleAppointment);
}
}
}
private void Logger_LogUpdated(string message)
{
Console.WriteLine(message);
}
[OneTimeTearDown]
public void TearDown()
{
sync.LogoffOutlook();
sync.LogoffGoogle();
}
[Test]
public void TestRemoveGoogleDuplicatedAppointments_01()
{
sync.SyncOption = SyncOption.OutlookToGoogleOnly;
// create new Outlook test appointment
var ola1 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.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.UpdateAppointment(ola1, ref e1);
var e2 = Factory.NewEvent();
AppointmentSync.UpdateAppointment(ola1, e2);
AppointmentPropertiesUtils.SetGoogleOutlookAppointmentId(sync.SyncProfile, e2, 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);
var oid_e2 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, e2);
var oid_ola1 = AppointmentPropertiesUtils.GetOutlookId(ola1);
// assert appointments ola1 and e1 are pointing to each other
Assert.AreEqual(gid_ola1, gid_e1);
Assert.AreEqual(oid_ola1, oid_e1);
// assert appointment e2 also points to ola1
Assert.AreEqual(oid_ola1, oid_e2);
// assert appointment ola1 does not point to e2
Assert.AreNotEqual(gid_ola1, gid_e2);
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, 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);
var f_oid_e2 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, f_e2);
var f_oid_ola1 = AppointmentPropertiesUtils.GetOutlookId(f_ola1);
// assert appointments ola1 and e1 are pointing to each other
Assert.AreEqual(f_gid_ola1, f_gid_e1);
Assert.AreEqual(f_oid_ola1, f_oid_e1);
// assert appointment e2 does not point to ola1
Assert.AreNotEqual(f_oid_ola1, f_oid_e2);
// assert appointment ola1 does not point to e2
Assert.AreNotEqual(f_gid_ola1, f_gid_e2);
DeleteTestAppointment(f_ola1);
DeleteTestAppointment(f_e1);
DeleteTestAppointment(f_e2);
}
[Test]
public void TestRemoveGoogleDuplicatedAppointments_02()
{
sync.SyncOption = SyncOption.OutlookToGoogleOnly;
// create new Outlook test appointment
var ola1 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.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.UpdateAppointment(ola1, ref e1);
var e2 = Factory.NewEvent();
AppointmentSync.UpdateAppointment(ola1, e2);
AppointmentPropertiesUtils.SetGoogleOutlookAppointmentId(sync.SyncProfile, e2, 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);
var oid_e2 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, e2);
var oid_ola1 = AppointmentPropertiesUtils.GetOutlookId(ola1);
// assert appointment e1 points to ola1
Assert.AreEqual(oid_ola1, oid_e1);
// assert appointment e2 points to ola1
Assert.AreEqual(oid_ola1, oid_e2);
// assert appointment ola1 does not point to e1
Assert.AreNotEqual(gid_ola1, gid_e1);
// assert appointment ola1 does not point to e2
Assert.AreNotEqual(gid_ola1, gid_e2);
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, 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);
var f_oid_e2 = AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, f_e2);
var f_oid_ola1 = AppointmentPropertiesUtils.GetOutlookId(f_ola1);
// assert appointment e1 does not point to ola1
Assert.AreNotEqual(f_oid_ola1, f_oid_e1);
// assert appointment ola1 does not point to e1
Assert.AreNotEqual(f_gid_ola1, f_gid_e1);
// assert appointment e2 does not point to ola1
Assert.AreNotEqual(f_oid_ola1, f_oid_e2);
// assert appointment ola1 does not point to e2
Assert.AreNotEqual(f_gid_ola1, f_gid_e2);
DeleteTestAppointment(f_ola1);
DeleteTestAppointment(f_e1);
DeleteTestAppointment(f_e2);
}
[Test]
public void TestRemoveOutlookDuplicatedAppointments_01()
{
sync.SyncOption = SyncOption.OutlookToGoogleOnly;
// create new Outlook test appointment
var ola1 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.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.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.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);
var oid_ola2 = AppointmentPropertiesUtils.GetOutlookId(ola2);
// assert appointments ola2 and e1 are pointing to each other
Assert.AreEqual(gid_ola2, gid_e1);
Assert.AreEqual(oid_ola2, oid_e1);
// assert appointment ola1 also points to e1
Assert.AreEqual(gid_ola1, gid_e1);
// assert appointment e1 does not point to ola1
Assert.AreNotEqual(oid_e1, oid_ola1);
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, 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);
var f_oid_ola2 = AppointmentPropertiesUtils.GetOutlookId(f_ola2);
// assert appointments ola2 and e1 are pointing to each other
Assert.AreEqual(f_gid_ola2, f_gid_e1);
Assert.AreEqual(f_oid_ola2, f_oid_e1);
// assert appointment ola1 does not point to e1
Assert.AreNotEqual(f_oid_ola1, f_oid_e1);
// assert appointment ola1 does not point to e1
Assert.AreNotEqual(f_gid_ola1, f_gid_e1);
DeleteTestAppointment(f_ola1);
DeleteTestAppointment(f_ola2);
DeleteTestAppointment(f_e1);
}
[Test]
public void TestRemoveOutlookDuplicatedAppointments_02()
{
sync.SyncOption = SyncOption.OutlookToGoogleOnly;
// create new Outlook test appointment
var ola1 = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.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.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.UpdateAppointment(ola2, ref e1);
AppointmentPropertiesUtils.ResetGoogleOutlookAppointmentId(sync.SyncProfile, e1);
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);
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.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, 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);
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);
}
[Test]
public void TestSync_Time()
{
sync.SyncOption = SyncOption.MergeOutlookWins;
// create new appointment to sync
var outlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.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.UpdateAppointment(outlookAppointment, ref googleAppointment);
googleAppointment = null;
sync.SyncOption = SyncOption.GoogleToOutlookOnly;
//load the same appointment from google.
MatchAppointments(sync);
var match = FindMatch(outlookAppointment);
Assert.IsNotNull(match);
Assert.IsNotNull(match.GoogleAppointment);
Assert.IsNotNull(match.OutlookAppointment);
var recreatedOutlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder);
sync.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();
}
[Test]
public void TestSync_Day()
{
sync.SyncOption = SyncOption.MergeOutlookWins;
// create new appointment to sync
var outlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder);
outlookAppointment.Subject = name;
outlookAppointment.Start = DateTime.Now;
outlookAppointment.End = DateTime.Now;
outlookAppointment.AllDayEvent = true;
outlookAppointment.Save();
sync.SyncOption = SyncOption.OutlookToGoogleOnly;
var googleAppointment = Factory.NewEvent();
sync.UpdateAppointment(outlookAppointment, ref googleAppointment);
googleAppointment = null;
sync.SyncOption = SyncOption.GoogleToOutlookOnly;
//load the same appointment from google.
MatchAppointments(sync);
var match = FindMatch(outlookAppointment);
Assert.IsNotNull(match);
Assert.IsNotNull(match.GoogleAppointment);
Assert.IsNotNull(match.OutlookAppointment);
var recreatedOutlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder);
sync.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();
}
[Test]
public void TestExtendedProps()
{
sync.SyncOption = SyncOption.MergeOutlookWins;
// create new appointment to sync
var outlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder);
outlookAppointment.Subject = name;
outlookAppointment.Start = DateTime.Now;
outlookAppointment.Start = DateTime.Now;
outlookAppointment.AllDayEvent = true;
outlookAppointment.Save();
var googleAppointment = Factory.NewEvent();
sync.UpdateAppointment(outlookAppointment, ref googleAppointment);
Assert.AreEqual(name, googleAppointment.Summary);
// read appointment from google
googleAppointment = null;
MatchAppointments(sync);
AppointmentsMatcher.SyncAppointments(sync);
var 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 void DeleteTestAppointments(AppointmentMatch match)
{
if (match != null)
{
DeleteTestAppointment(match.GoogleAppointment);
DeleteTestAppointment(match.OutlookAppointment);
}
}
private void DeleteTestAppointment(Outlook.AppointmentItem ola)
{
if (ola != null)
{
var name = ola.Subject;
ola.Delete();
Logger.Log("Deleted Outlook test appointment: " + name, EventType.Information);
}
}
private void DeleteTestAppointment(Event e)
{
if (e != null && !e.Status.Equals("cancelled"))
{
sync.EventRequest.Delete(Synchronizer.SyncAppointmentsGoogleFolder, e.Id);
Logger.Log("Deleted Google test appointment: " + e.Summary, EventType.Information);
//Thread.Sleep(2000);
}
}
internal AppointmentMatch FindMatch(Outlook.AppointmentItem ola)
{
foreach (var match in sync.Appointments)
{
if (match.OutlookAppointment != null && match.OutlookAppointment.EntryID == ola.EntryID)
{
return match;
}
}
return null;
}
private void MatchAppointments(Synchronizer sync)
{
//Thread.Sleep(5000); //Wait, until Appointment is really saved and available to retrieve again
sync.MatchAppointments();
}
internal AppointmentMatch FindMatch(Event e)
{
if (e != null)
{
foreach (var match in sync.Appointments)
{
if (match.GoogleAppointment != null && match.GoogleAppointment.Id == e.Id)
{
return match;
}
}
}
return null;
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.