Handle() public method

Filters FSEvents if they signalize an add and are handled already. This occurs if the syncer creates a local object on file system.
public Handle ( ISyncEvent e ) : bool
e ISyncEvent Sync event
return bool
 public void FilterIgnoresNonExistingPaths() {
     var storage = new Mock<IMetaDataStorage>();
     var fsFactory = new Mock<IFileSystemInfoFactory>();
     var filter = new IgnoreAlreadyHandledFsEventsFilter(storage.Object, fsFactory.Object);
     var fsEvent = new FSEvent(WatcherChangeTypes.Created, Path.Combine(Path.GetTempPath(), "path"), true);
     Assert.That(filter.Handle(fsEvent), Is.False);
 }
        public void FilterHandlesAlreadyExistingFolderEntries() {
            string path = "path";
            var storage = new Mock<IMetaDataStorage>();
            var fsFactory = new Mock<IFileSystemInfoFactory>();
            var filter = new IgnoreAlreadyHandledFsEventsFilter(storage.Object, fsFactory.Object);
            var fsEvent = new Mock<IFSEvent>();
            fsEvent.Setup(e => e.IsDirectory).Returns(true);
            fsEvent.Setup(e => e.LocalPath).Returns(path);
            fsEvent.Setup(e => e.Type).Returns(WatcherChangeTypes.Created);
            fsFactory.AddDirectory(path);
            storage.Setup(s => s.GetObjectByLocalPath(It.Is<IFileSystemInfo>(p => p.FullName.Equals(path)))).Returns(Mock.Of<IMappedObject>());

            Assert.That(filter.Handle(fsEvent.Object), Is.True);
        }
        public void FilterHandlesAlreadyMovedFolderEntries() {
            string path = "path";
            string oldPath = "oldpath";
            Guid guid = Guid.NewGuid();
            var storage = new Mock<IMetaDataStorage>();
            var fsFactory = new Mock<IFileSystemInfoFactory>(MockBehavior.Strict);
            var moveEvent = Mock.Of<IFSMovedEvent>(e => e.LocalPath == path && e.OldPath == oldPath && e.Type == WatcherChangeTypes.Renamed && e.IsDirectory == true);
            var dirInfo = Mock.Of<IDirectoryInfo>(d => d.FullName == path && d.Exists == true && d.Uuid == guid);
            fsFactory.AddIDirectoryInfo(dirInfo);
            storage.AddMappedFolder(new MappedObject("path", "remoteId", MappedObjectType.Folder, null, null) { Guid = guid }, path);
            var filter = new IgnoreAlreadyHandledFsEventsFilter(storage.Object, fsFactory.Object);

            Assert.That(filter.Handle(moveEvent), Is.True);
        }
 public void FilterIgnoresNonFsEvents() {
     var filter = new IgnoreAlreadyHandledFsEventsFilter(Mock.Of<IMetaDataStorage>(), Mock.Of<IFileSystemInfoFactory>());
     Assert.That(filter.Handle(Mock.Of<ISyncEvent>()), Is.False);
 }
        public void FilterDeletesFsEventsIfLocalFileSystemContainsTheElementOfTheStorage() {
            string path = "path";
            Guid guid = Guid.NewGuid();
            var storage = new Mock<IMetaDataStorage>();
            var fsFactory = new Mock<IFileSystemInfoFactory>();
            fsFactory.AddFile(path, guid, true);
            storage.AddLocalFile(path, "id", guid);
            var filter = new IgnoreAlreadyHandledFsEventsFilter(storage.Object, fsFactory.Object);
            var fsEvent = Mock.Of<IFSEvent>(
                e =>
                e.LocalPath == path &&
                e.Type == WatcherChangeTypes.Deleted &&
                e.IsDirectory== false);

            Assert.That(filter.Handle(fsEvent), Is.True);
        }
        public void FilterDeleteFsEventsIfNoCorrespondingElementExistsInStorage() {
            string path = "path";
            var filter = new IgnoreAlreadyHandledFsEventsFilter(Mock.Of<IMetaDataStorage>(), Mock.Of<IFileSystemInfoFactory>());
            var fsEvent = new Mock<IFSEvent>();
            fsEvent.Setup(e => e.LocalPath).Returns(path);
            fsEvent.Setup(e => e.Type).Returns(WatcherChangeTypes.Deleted);
            fsEvent.Setup(e => e.IsDirectory).Returns(false);

            Assert.That(filter.Handle(fsEvent.Object), Is.True);
        }