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)); }
public static Mock <IMappedObject> AddLocalFile(this Mock <IMetaDataStorage> db, IFileInfo path, string id) { var file = Mock.Of <IMappedObject>(f => f.RemoteObjectId == id && f.Name == path.Name && f.Type == MappedObjectType.File); db.AddMappedFile(file, path.FullName); return(Mock.Get(file)); }
public static void AddLocalFile(this Mock <IMetaDataStorage> db, string path, string id, Guid uuid) { var file = Mock.Of <IMappedObject>(f => f.RemoteObjectId == id && f.Name == Path.GetFileName(path) && f.Guid == uuid && f.Type == MappedObjectType.File); db.AddMappedFile(file, path); }
public static Mock <IMappedObject> AddLocalFile(this Mock <IMetaDataStorage> db, IFileInfo path, string id) { var file = new Mock <IMappedObject>(); file.SetupAllProperties(); file.Setup(o => o.Type).Returns(MappedObjectType.File); file.Object.RemoteObjectId = id; file.Object.Name = path.Name; db.AddMappedFile(file.Object, path.FullName); return(file); }
public static void AddLocalFile(this Mock <IMetaDataStorage> db, string path, string id, Guid uuid) { var file = new Mock <IMappedObject>(); file.SetupAllProperties(); file.Setup(o => o.Type).Returns(MappedObjectType.File); file.Object.RemoteObjectId = id; file.Object.Name = Path.GetFileName(path); file.Object.Guid = uuid; db.AddMappedFile(file.Object, path); }
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)); }