Beispiel #1
0
        public void FindsMatchingEntites()
        {
            OutlookTestContext.DeleteAllOutlookEvents();

            var id1 = OutlookTestContext.CreateEventInOutlook("first", DateTime.Now.AddDays(11), DateTime.Now.AddDays(20));
            var id2 = OutlookTestContext.CreateEventInOutlook("second", DateTime.Now.AddDays(-11), DateTime.Now.AddDays(-9));
            var id3 = OutlookTestContext.CreateEventInOutlook("third", DateTime.Now.AddDays(9), DateTime.Now.AddDays(11));

            var entityRelationStorage = new InMemoryEntityRelationStorage();
            var calDavServer          = new InMemoryCalDAVServer();

            var synchronizer = OutlookTestContext.CreateEventSynchronizer(
                SynchronizationMode.ReplicateOutlookIntoServer,
                calDavServer,
                entityRelationStorage);


            OutlookTestContext.WaitForTask(synchronizer.Synchronize(NullSynchronizationLogger.Instance));

            var entityRelationDatas = entityRelationStorage.LoadEntityRelationData().ToArray();

            Assert.That(entityRelationDatas.Length, Is.EqualTo(3));

            var newEntityRelationStorage = new InMemoryEntityRelationStorage();

            synchronizer = OutlookTestContext.CreateEventSynchronizer(
                SynchronizationMode.MergeInBothDirections,
                calDavServer,
                newEntityRelationStorage);

            OutlookTestContext.WaitForTask(synchronizer.Synchronize(NullSynchronizationLogger.Instance));

            var newRelations = newEntityRelationStorage.LoadEntityRelationData().ToArray();

            // If the InitialEntityMatcher would not work, it would not recognize matching events
            // and number of events would be doubled, since each repository contains 3 events and mode is MergeInBothDirections
            Assert.That(newRelations.Length, Is.EqualTo(3));

            // the new found relkations must be the same as the existing ones
            foreach (var newRelation in newRelations)
            {
                Assert.That(
                    entityRelationDatas.FirstOrDefault(o => o.AtypeId == newRelation.AtypeId &&
                                                       o.AtypeVersion == newRelation.AtypeVersion &&
                                                       o.BtypeId == newRelation.BtypeId &&
                                                       o.BtypeVersion == newRelation.BtypeVersion),
                    Is.Not.Null);
            }
        }
    public void FindsMatchingEntites ()
    {
      OutlookTestContext.DeleteAllOutlookEvents();

      var id1 = OutlookTestContext.CreateEventInOutlook ("first", DateTime.Now.AddDays (11), DateTime.Now.AddDays (20));
      var id2 = OutlookTestContext.CreateEventInOutlook ("second", DateTime.Now.AddDays (-11), DateTime.Now.AddDays (-9));
      var id3 = OutlookTestContext.CreateEventInOutlook ("third", DateTime.Now.AddDays (9), DateTime.Now.AddDays (11));

      var entityRelationStorage = new InMemoryEntityRelationStorage();
      var calDavServer = new InMemoryCalDAVServer();

      var synchronizer = OutlookTestContext.CreateEventSynchronizer (
          SynchronizationMode.ReplicateOutlookIntoServer,
          calDavServer,
          entityRelationStorage);


      OutlookTestContext.WaitForTask (synchronizer.SynchronizeNoThrow(NullSynchronizationLogger.Instance));

      var entityRelationDatas = entityRelationStorage.LoadEntityRelationData().ToArray();
      Assert.That (entityRelationDatas.Length, Is.EqualTo (3));

      var newEntityRelationStorage = new InMemoryEntityRelationStorage();

      synchronizer = OutlookTestContext.CreateEventSynchronizer (
          SynchronizationMode.MergeInBothDirections,
          calDavServer,
          newEntityRelationStorage);

      OutlookTestContext.WaitForTask (synchronizer.SynchronizeNoThrow (NullSynchronizationLogger.Instance));

      var newRelations = newEntityRelationStorage.LoadEntityRelationData().ToArray();
      // If the InitialEntityMatcher would not work, it would not recognize matching events 
      // and number of events would be doubled, since each repository contains 3 events and mode is MergeInBothDirections
      Assert.That (newRelations.Length, Is.EqualTo (3));

      // the new found relkations must be the same as the existing ones
      foreach (var newRelation in newRelations)
      {
        Assert.That (
            entityRelationDatas.FirstOrDefault (o => o.AtypeId == newRelation.AtypeId
                                                     && o.AtypeVersion == newRelation.AtypeVersion
                                                     && o.BtypeId == newRelation.BtypeId
                                                     && o.BtypeVersion == newRelation.BtypeVersion),
            Is.Not.Null);
      }
    }
    public static string SyncOutlookToCalDav_EventsExistsInCalDav (string existingEventData, string existingAppointmentId)
    {
      var entityRelationStorage = new InMemoryEntityRelationStorage<string, DateTime, IEntityRelationData<string, DateTime, Uri, string>, Uri, string>();
      entityRelationStorage.SaveEntityRelationData (new List<IEntityRelationData<string, DateTime, Uri, string>>()
                                                    {
                                                        new OutlookEventRelationData()
                                                        {
                                                            AtypeId = existingAppointmentId,
                                                            AtypeVersion = new DateTime (1),
                                                            BtypeId = new Uri ("/e1", UriKind.Relative),
                                                            BtypeVersion = "v1"
                                                        }
                                                    });

      return SyncOutlookToCalDav_EventsExistsInCalDav (existingEventData, entityRelationStorage);
    }
    public static string SyncCalDavToOutlookAndBackToCalDav (string eventData)
    {
      var entityRelationStorage = new InMemoryEntityRelationStorage<string, DateTime, IEntityRelationData<string, DateTime, Uri, string>, Uri, string>();

      SyncCalDavToOutlook (eventData, entityRelationStorage);

      var relation = entityRelationStorage.LoadEntityRelationData().First();
      var newRelation = new OutlookEventRelationData()
                        {
                            AtypeId = relation.AtypeId,
                            AtypeVersion = relation.AtypeVersion.AddHours (-1),
                            BtypeId = relation.BtypeId,
                            BtypeVersion = relation.BtypeVersion
                        };
      entityRelationStorage.SaveEntityRelationData (new List<IEntityRelationData<string, DateTime, Uri, string>>() { newRelation });

      return SyncOutlookToCalDav_EventsExistsInCalDav (eventData, entityRelationStorage);
    }
    public static string SyncOutlookToCalDav_EventsExistsInCalDav (string existingEventData, AppointmentId existingAppointmentId)
    {
      var entityRelationStorage = new InMemoryEntityRelationStorage<AppointmentId, DateTime, IEntityRelationData<AppointmentId, DateTime, WebResourceName, string>, WebResourceName, string>();
      entityRelationStorage.SaveEntityRelationData (new List<IEntityRelationData<AppointmentId, DateTime, WebResourceName, string>>()
                                                    {
                                                        new OutlookEventRelationData()
                                                        {
                                                            AtypeId = existingAppointmentId,
                                                            AtypeVersion = new DateTime (1),
                                                            BtypeId = new WebResourceName("/e1"),
                                                            BtypeVersion = "v1"
                                                        }
                                                    });

      return SyncOutlookToCalDav_EventsExistsInCalDav (existingEventData, entityRelationStorage);
    }