Handle() public method

Handle the specified e.
/// Is thrown when an operation cannot be performed. ///
public Handle ( ISyncEvent e ) : bool
e ISyncEvent /// The ISyncEvent only handled when ContentChangeEvent ///
return bool
 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 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 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));
        }
        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));
        }