public Handle ( ISyncEvent e ) : bool | ||
e | ISyncEvent | The event to handle. |
Результат | bool |
public void IgnoresWrongEvent() { var storage = new Mock<IMetaDataStorage>(); var queue = new Mock<ISyncEventQueue>(); var session = new Mock<ISession>(); var changes = new ContentChanges(session.Object, storage.Object, queue.Object); var startSyncEvent = new Mock<ISyncEvent>().Object; Assert.IsFalse(changes.Handle(startSyncEvent)); }
public void GivesCorrectContentChangeEvent() { ContentChangeEvent contentChangeEvent = null; var queue = new Mock<ISyncEventQueue>(); queue.Setup(q => q.AddEvent(It.IsAny<ContentChangeEvent>())).Callback((ISyncEvent f) => { contentChangeEvent = f as ContentChangeEvent; }); string id = "myId"; Mock<IMetaDataStorage> storage = MockMetaDataStorageUtil.GetMetaStorageMockWithToken(); var session = MockSessionUtil.PrepareSessionMockForSingleChange(DotCMIS.Enums.ChangeType.Created, id); var changes = new ContentChanges(session.Object, storage.Object, queue.Object, this.maxNumberOfContentChanges, this.isPropertyChangesSupported); var startSyncEvent = new StartNextSyncEvent(false); Assert.IsTrue(changes.Handle(startSyncEvent)); queue.Verify(foo => foo.AddEvent(It.IsAny<ContentChangeEvent>()), Times.Once()); Assert.That(contentChangeEvent.Type, Is.EqualTo(DotCMIS.Enums.ChangeType.Created)); Assert.That(contentChangeEvent.ObjectId, Is.EqualTo(id)); }
public void IgnoreDuplicatedContentChangesEventTestDeleted() { var queue = new Mock<ISyncEventQueue>(); Mock<IMetaDataStorage> storage = MockMetaDataStorageUtil.GetMetaStorageMockWithToken(); Mock<ISession> session = MockSessionUtil.GetSessionMockReturning3Changesin2Batches(DotCMIS.Enums.ChangeType.Deleted, true); var startSyncEvent = new StartNextSyncEvent(false); var changes = new ContentChanges(session.Object, storage.Object, queue.Object, this.maxNumberOfContentChanges, this.isPropertyChangesSupported); Assert.IsTrue(changes.Handle(startSyncEvent)); queue.Verify(foo => foo.AddEvent(It.IsAny<ContentChangeEvent>()), Times.Exactly(3)); }
public void ExtendCrawlSyncEvent() { var start = new StartNextSyncEvent(true); var repositoryService = new Mock<IRepositoryService>(); repositoryService.Setup(r => r.GetRepositoryInfos(null)).Returns((IList<IRepositoryInfo>)null); repositoryService.Setup(r => r.GetRepositoryInfo(It.IsAny<string>(), It.IsAny<IExtensionsData>()).LatestChangeLogToken).Returns(this.latestChangeLogToken); var session = new Mock<ISession>(); session.Setup(s => s.Binding.GetRepositoryService()).Returns(repositoryService.Object); session.Setup(s => s.RepositoryInfo.Id).Returns(this.repoId); var manager = new Mock<ISyncEventManager>().Object; var storage = new Mock<IMetaDataStorage>(); storage.Setup(db => db.ChangeLogToken).Returns((string)null); var queue = new Mock<ISyncEventQueue>(); var changes = new ContentChanges(session.Object, storage.Object, queue.Object); Assert.IsFalse(changes.Handle(start)); Assert.AreEqual(this.latestChangeLogToken, start.LastTokenOnServer); }
public void ExecuteCrawlSyncOnNoLocalTokenAvailable() { var startSyncEvent = new StartNextSyncEvent(false); var session = new Mock<ISession>(); session.SetupSessionDefaultValues(); session.Setup(s => s.Binding.GetRepositoryService().GetRepositoryInfo(this.repoId, null).LatestChangeLogToken).Returns(this.changeLogToken); var storage = new Mock<IMetaDataStorage>(); storage.Setup(db => db.ChangeLogToken).Returns((string)null); var queue = new Mock<ISyncEventQueue>(); var changes = new ContentChanges(session.Object, storage.Object, queue.Object); Assert.IsTrue(changes.Handle(startSyncEvent)); queue.Verify(q => q.AddEvent(It.Is<StartNextSyncEvent>(e => e.FullSyncRequested == true)), Times.Once()); }
public void HandleStartSyncEventOnNoRemoteChange() { var startSyncEvent = new StartNextSyncEvent(false); var session = new Mock<ISession>(); session.SetupSessionDefaultValues(); session.Setup(s => s.Binding.GetRepositoryService().GetRepositoryInfo(this.repoId, null).LatestChangeLogToken).Returns(this.changeLogToken); var storage = new Mock<IMetaDataStorage>(); storage.Setup(db => db.ChangeLogToken).Returns(this.changeLogToken); var queue = new Mock<ISyncEventQueue>(); var changes = new ContentChanges(session.Object, storage.Object, queue.Object); Assert.IsTrue(changes.Handle(startSyncEvent)); }
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); }
public void RetrunFalseOnError() { // TODO: this might not be the best behavior, this test verifies the current implementation not the desired one var storage = new Mock<IMetaDataStorage>(); var queue = new Mock<ISyncEventQueue>(); var session = new Mock<ISession>(); session.Setup(x => x.Binding).Throws(new Exception("SOME EXCEPTION")); var changes = new ContentChanges(session.Object, storage.Object, queue.Object); var wrongEvent = new Mock<ISyncEvent>().Object; Assert.IsFalse(changes.Handle(wrongEvent)); }