public void IgnoreDifferentEvent() { var storage = new Mock<IMetaDataStorage>(); var queue = new Mock<ISyncEventQueue>(); var e = new Mock<ISyncEvent>(); var transformer = new ContentChangeEventTransformer(queue.Object, storage.Object); Assert.That(transformer.Handle(e.Object), Is.False); }
public void IgnoreNotAccumulatedNonDeleteEvent() { var storage = new Mock<IMetaDataStorage>(); var queue = new Mock<ISyncEventQueue>(); var e = new ContentChangeEvent(DotCMIS.Enums.ChangeType.Created, Id); var transformer = new ContentChangeEventTransformer(queue.Object, storage.Object); Assert.Throws<InvalidOperationException>(() => transformer.Handle(e)); }
public void DocumentCreationWithContent() { var storage = new Mock<IMetaDataStorage>(); FileEvent fileEvent = null; var queue = new Mock<ISyncEventQueue>(); queue.Setup(h => h.AddEvent(It.IsAny<FileEvent>())) .Callback<ISyncEvent>(e => fileEvent = e as FileEvent); var transformer = new ContentChangeEventTransformer(queue.Object, storage.Object); var contentChangeEvent = this.PrepareEvent(DotCMIS.Enums.ChangeType.Created, true); Assert.That(transformer.Handle(contentChangeEvent), Is.True); queue.Verify(q => q.AddEvent(It.IsAny<FileEvent>()), Times.Once()); Assert.That(fileEvent.Remote, Is.EqualTo(MetaDataChangeType.CREATED)); Assert.That(fileEvent.RemoteContent, Is.EqualTo(ContentChangeType.CREATED)); }
private ObservableHandler RunQueue(Mock<ISession> session, Mock<IMetaDataStorage> storage) { var manager = new SyncEventManager(); var observer = new ObservableHandler(); manager.AddEventHandler(observer); SingleStepEventQueue queue = new SingleStepEventQueue(manager); var changes = new ContentChanges(session.Object, storage.Object, queue, this.maxNumberOfContentChanges, this.isPropertyChangesSupported); manager.AddEventHandler(changes); var transformer = new ContentChangeEventTransformer(queue, storage.Object); manager.AddEventHandler(transformer); var accumulator = new ContentChangeEventAccumulator(session.Object, queue); manager.AddEventHandler(accumulator); queue.RunStartSyncEvent(); return observer; }
private SingleStepEventQueue CreateQueue(Mock<ISession> session, IMetaDataStorage storage, ObservableHandler observer, IFileSystemInfoFactory fsFactory = null) { var manager = new SyncEventManager(); SingleStepEventQueue queue = new SingleStepEventQueue(manager); manager.AddEventHandler(observer); var connectionScheduler = new ConnectionScheduler(new RepoInfo(), queue, Mock.Of<ISessionFactory>(), Mock.Of<IAuthenticationProvider>()); manager.AddEventHandler(connectionScheduler); var changes = new ContentChanges(session.Object, storage, queue, this.maxNumberOfContentChanges, this.isPropertyChangesSupported); manager.AddEventHandler(changes); var transformer = new ContentChangeEventTransformer(queue, storage, fsFactory); manager.AddEventHandler(transformer); var ccaccumulator = new ContentChangeEventAccumulator(session.Object, queue); manager.AddEventHandler(ccaccumulator); var remoteFetcher = new RemoteObjectFetcher(session.Object, storage); manager.AddEventHandler(remoteFetcher); var localFetcher = new LocalObjectFetcher(storage.Matcher, fsFactory); manager.AddEventHandler(localFetcher); var watcher = new Strategy.WatcherConsumer(queue); manager.AddEventHandler(watcher); var localDetection = new LocalSituationDetection(); var remoteDetection = new RemoteSituationDetection(); var transmissionManager = new TransmissionManager(); var activityAggregator = new ActivityListenerAggregator(Mock.Of<IActivityListener>(), transmissionManager); var ignoreFolderFilter = new IgnoredFoldersFilter(); var ignoreFolderNameFilter = new IgnoredFolderNameFilter(); var ignoreFileNamesFilter = new IgnoredFileNamesFilter(); var invalidFolderNameFilter = new InvalidFolderNameFilter(); var filterAggregator = new FilterAggregator(ignoreFileNamesFilter, ignoreFolderNameFilter, invalidFolderNameFilter, ignoreFolderFilter); var syncMechanism = new SyncMechanism(localDetection, remoteDetection, queue, session.Object, storage, Mock.Of<IFileTransmissionStorage>(), activityAggregator, filterAggregator); manager.AddEventHandler(syncMechanism); var remoteFolder = MockSessionUtil.CreateCmisFolder(); remoteFolder.Setup(r => r.Path).Returns(this.remoteRoot); var localFolder = new Mock<IDirectoryInfo>(); localFolder.Setup(f => f.FullName).Returns(this.localRoot); var generator = new CrawlEventGenerator(storage, fsFactory); var ignoreStorage = new IgnoredEntitiesStorage(new IgnoredEntitiesCollection(), storage); var treeBuilder = new DescendantsTreeBuilder(storage, remoteFolder.Object, localFolder.Object, filterAggregator, ignoreStorage); var notifier = new CrawlEventNotifier(queue); var crawler = new DescendantsCrawler(queue, treeBuilder, generator, notifier, Mock.Of<IActivityListener>()); manager.AddEventHandler(crawler); var permissionDenied = new GenericHandleDublicatedEventsFilter<PermissionDeniedEvent, ConfigChangedEvent>(); manager.AddEventHandler(permissionDenied); var alreadyAddedFilter = new IgnoreAlreadyHandledFsEventsFilter(storage, fsFactory); manager.AddEventHandler(alreadyAddedFilter); var ignoreContentChangesFilter = new IgnoreAlreadyHandledContentChangeEventsFilter(storage, session.Object); manager.AddEventHandler(ignoreContentChangesFilter); var delayRetryAndNextSyncEventHandler = new DelayRetryAndNextSyncEventHandler(queue); manager.AddEventHandler(delayRetryAndNextSyncEventHandler); /* This is not implemented yet var failedOperationsFilder = new FailedOperationsFilter(queue); manager.AddEventHandler(failedOperationsFilder); */ var reportingFilter = new ReportingFilter(queue, ignoreFolderFilter, ignoreFileNamesFilter, ignoreFolderNameFilter, invalidFolderNameFilter, new SymlinkFilter()); manager.AddEventHandler(reportingFilter); var debugHandler = new DebugLoggingHandler(); manager.AddEventHandler(debugHandler); var movedOrRenamed = new RemoteObjectMovedOrRenamedAccumulator(queue, storage, fsFactory); manager.AddEventHandler(movedOrRenamed); return queue; }
public void ConstructorTest() { var storage = new Mock<IMetaDataStorage>(); var queue = new Mock<ISyncEventQueue>(); var transformer = new ContentChangeEventTransformer(queue.Object, storage.Object); Assert.That(transformer.Priority, Is.EqualTo(1000)); }
public void RemoteFolderSecurity() { var storage = new Mock<IMetaDataStorage>(); storage.AddLocalFolder("path", Id); FolderEvent folderEvent = null; var queue = new Mock<ISyncEventQueue>(); queue.Setup(h => h.AddEvent(It.IsAny<FolderEvent>())) .Callback<ISyncEvent>(e => folderEvent = e as FolderEvent); var transformer = new ContentChangeEventTransformer(queue.Object, storage.Object); var contentChangeEvent = this.PrepareFolderEvent(DotCMIS.Enums.ChangeType.Security); Assert.That(transformer.Handle(contentChangeEvent), Is.True); queue.Verify(q => q.AddEvent(It.IsAny<FolderEvent>()), Times.Once()); Assert.That(folderEvent.Remote, Is.EqualTo(MetaDataChangeType.CHANGED)); }
public void RemoteFolderDeletionWithoutLocalFolder() { var storage = new Mock<IMetaDataStorage>(); var queue = new Mock<ISyncEventQueue>(); var transformer = new ContentChangeEventTransformer(queue.Object, storage.Object); var contentChangeEvent = this.PrepareFolderEvent(DotCMIS.Enums.ChangeType.Deleted); Assert.That(transformer.Handle(contentChangeEvent), Is.True); queue.Verify(q => q.AddEvent(It.IsAny<ISyncEvent>()), Times.Never()); }
public void RemoteDeletionChangeTest() { var storage = new Mock<IMetaDataStorage>(); storage.AddLocalFile("path", Id); FileEvent fileEvent = null; var queue = new Mock<ISyncEventQueue>(); queue.Setup(h => h.AddEvent(It.IsAny<FileEvent>())) .Callback<ISyncEvent>(e => fileEvent = e as FileEvent); var transformer = new ContentChangeEventTransformer(queue.Object, storage.Object); var contentChangeEvent = this.PrepareEvent(DotCMIS.Enums.ChangeType.Deleted, false); Assert.That(transformer.Handle(contentChangeEvent), Is.True); queue.Verify(q => q.AddEvent(It.IsAny<FileEvent>()), Times.Once()); Assert.That(fileEvent.Remote, Is.EqualTo(MetaDataChangeType.DELETED)); Assert.That(fileEvent.RemoteContent, Is.EqualTo(ContentChangeType.NONE)); }
public void LocallyExistingRemoteDocumentUpdatedButContentStaysEqual() { byte[] hash = new byte[20]; string type = "SHA-1"; string fileName = "file.bin"; var storage = new Mock<IMetaDataStorage>(); var file = Mock.Of<IMappedObject>( f => f.RemoteObjectId == Id && f.Name == fileName && f.Type == MappedObjectType.File && f.ChecksumAlgorithmName == type && f.LastChecksum == hash); storage.AddMappedFile(file); storage.Setup(s => s.GetLocalPath(It.Is<IMappedObject>(o => o.Equals(file)))).Returns("path"); FileEvent fileEvent = null; var queue = new Mock<ISyncEventQueue>(); queue.Setup( h => h.AddEvent(It.IsAny<FileEvent>())) .Callback<ISyncEvent>(e => fileEvent = e as FileEvent); var transformer = new ContentChangeEventTransformer(queue.Object, storage.Object); var contentChangeEvent = this.PrepareEvent(DotCMIS.Enums.ChangeType.Updated, false, hash); Assert.That(transformer.Handle(contentChangeEvent), Is.True); queue.Verify(q => q.AddEvent(It.IsAny<FileEvent>()), Times.Once()); Assert.That(fileEvent.Remote, Is.EqualTo(MetaDataChangeType.CHANGED)); Assert.That(fileEvent.RemoteContent, Is.EqualTo(ContentChangeType.NONE)); }