예제 #1
0
        public void ContructorTest()
        {
            var start    = new Mock <StartNextSyncEvent>(false).Object;
            var complete = new FullSyncCompletedEvent(start);

            Assert.AreEqual(start, complete.StartEvent);
        }
예제 #2
0
        public void HandleFullSyncCompletedEvent()
        {
            var startSyncEvent = new StartNextSyncEvent(false);

            startSyncEvent.LastTokenOnServer = this.changeLogToken;
            var completedEvent = new FullSyncCompletedEvent(startSyncEvent);
            var storage        = new Mock <IMetaDataStorage>();

            storage.SetupProperty(db => db.ChangeLogToken);
            var queue   = new Mock <ISyncEventQueue>();
            var session = new Mock <ISession>();
            var changes = new ContentChanges(session.Object, storage.Object, queue.Object);

            Assert.IsFalse(changes.Handle(completedEvent));
            storage.VerifySet(db => db.ChangeLogToken = this.changeLogToken);
            Assert.AreEqual(this.changeLogToken, storage.Object.ChangeLogToken);
        }
예제 #3
0
        /// <summary>
        /// Handle the specified e.
        /// </summary>
        /// <param name="e">The event to handle.</param>
        /// <returns>true if handled</returns>
        public override bool Handle(ISyncEvent e)
        {
            StartNextSyncEvent syncEvent = e as StartNextSyncEvent;

            if (syncEvent != null)
            {
                if (syncEvent.FullSyncRequested)
                {
                    // Get last change log token on server side.
                    string lastRemoteChangeLogTokenBeforeFullCrawlSync = this.session.Binding.GetRepositoryService().GetRepositoryInfo(this.session.RepositoryInfo.Id, null).LatestChangeLogToken;
                    if (this.storage.ChangeLogToken == null)
                    {
                        syncEvent.LastTokenOnServer = lastRemoteChangeLogTokenBeforeFullCrawlSync;
                    }

                    // Use fallback sync algorithm
                    return(false);
                }
                else
                {
                    Logger.Debug("Starting ContentChange Sync");
                    bool result = this.StartSync();
                    return(result);
                }
            }

            // The above started full sync is finished.
            FullSyncCompletedEvent syncCompleted = e as FullSyncCompletedEvent;

            if (syncCompleted != null)
            {
                string lastTokenOnServer = syncCompleted.StartEvent.LastTokenOnServer;
                if (!string.IsNullOrEmpty(lastTokenOnServer))
                {
                    this.storage.ChangeLogToken = lastTokenOnServer;
                }
            }

            return(false);
        }