Local object fetcher. I generates IFileSystemInfo if none found in FileEvent or FolderEvent
/// Is thrown when an argument passed to a method is invalid because it is . ///
Inheritance: SyncEventHandler
        public void IgnoresOtherEvents() {
            var matcher = new Mock<IPathMatcher>();

            var syncEvent = new Mock<ISyncEvent>();
            var fetcher = new LocalObjectFetcher(matcher.Object);

            Assert.That(fetcher.Handle(syncEvent.Object), Is.False);
        }
        public void FetchLocalFolder() {
            var localPath = Path.GetTempPath();
            var remotePath = Path.Combine(Path.GetTempPath(), "a");

            var matcher = new Mock<IPathMatcher>();
            matcher.Setup(m => m.CreateLocalPath(remotePath)).Returns(localPath);
            matcher.Setup(m => m.CanCreateLocalPath(remotePath)).Returns(true);

            var remoteFolder = new Mock<IFolder>();
            remoteFolder.Setup(f => f.Path).Returns(remotePath);

            var folderEvent = new FolderEvent(remoteFolder: remoteFolder.Object);
            var fetcher = new LocalObjectFetcher(matcher.Object);

            Assert.That(fetcher.Handle(folderEvent), Is.False);
            Assert.That(folderEvent.LocalFolder, Is.Not.Null);
            Assert.That(folderEvent.LocalFolder.FullName, Is.EqualTo(localPath));
        }
        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 FetchLocalFile() {
            var localPath = Path.GetTempPath();
            var remotePath = Path.Combine(Path.GetTempPath(), "a");

            var matcher = new Mock<IPathMatcher>();
            matcher.Setup(m => m.CreateLocalPath(remotePath)).Returns(localPath);
            matcher.Setup(m => m.CanCreateLocalPath(remotePath)).Returns(true);

            var remoteFile = new Mock<IDocument>();
            remoteFile.Setup(f => f.Paths).Returns(new string[] { remotePath });

            var fileEvent = new FileEvent(remoteFile: remoteFile.Object);
            var fetcher = new LocalObjectFetcher(matcher.Object);

            Assert.That(fetcher.Handle(fileEvent), Is.False);
            Assert.That(fileEvent.LocalFile, Is.Not.Null);
            Assert.That(fileEvent.LocalFile.FullName, Is.EqualTo(localPath));
        }
        public void FetchOnlyIfLocalFolderNull() {
            var matcher = new Mock<IPathMatcher>();

            var remoteFolder = new Mock<IFolder>();

            var folder = new Mock<IDirectoryInfo>();

            var folderEvent = new FolderEvent(remoteFolder: remoteFolder.Object, localFolder: folder.Object);
            var fetcher = new LocalObjectFetcher(matcher.Object);

            Assert.That(fetcher.Handle(folderEvent), Is.False);
            Assert.That(folderEvent.LocalFolder, Is.EqualTo(folder.Object));
        }
        public void DropFolderEventIfPathMatcherCannotCreateLocalPath() {
            var remotePath = Path.Combine(Path.GetTempPath(), "a");

            var matcher = new Mock<IPathMatcher>();
            matcher.Setup(m => m.CanCreateLocalPath(remotePath)).Returns(false);

            var remoteFolder = new Mock<IFolder>();
            remoteFolder.Setup(f => f.Path).Returns(remotePath);

            var folderEvent = new FolderEvent(remoteFolder: remoteFolder.Object);
            var fetcher = new LocalObjectFetcher(matcher.Object);

            Assert.That(fetcher.Handle(folderEvent), Is.True);
            Assert.That(folderEvent.LocalFolder, Is.Null);
        }
        public void FetchOnlyIfLocalFileNull() {
            var matcher = new Mock<IPathMatcher>();

            var remoteFile = new Mock<IDocument>();

            var file = new Mock<IFileInfo>();

            var fileEvent = new FileEvent(remoteFile: remoteFile.Object, localFile: file.Object);
            var fetcher = new LocalObjectFetcher(matcher.Object);

            Assert.That(fetcher.Handle(fileEvent), Is.False);
            Assert.That(fileEvent.LocalFile, Is.EqualTo(file.Object));
        }