public void MoveObjectToSubfolder() { var remoteFolder = MockOfIFolderUtil.CreateRemoteFolderMock("folderId", "folder", "/folder", this.rootId); var remoteTargetFolder = MockOfIFolderUtil.CreateRemoteFolderMock("targetId", "target", "/target", this.rootId); this.session.AddRemoteObjects(remoteFolder.Object, remoteTargetFolder.Object); var localTargetFolder = MockOfIFileSystemInfoFactoryUtil.CreateLocalFolder(Path.Combine(Path.GetTempPath(), "target")); var localFolder = MockOfIFileSystemInfoFactoryUtil.CreateLocalFolder(Path.Combine(Path.GetTempPath(), "target", "folder")); localFolder.Setup(f => f.Parent).Returns(localTargetFolder.Object); var mappedFolder = new MappedObject("folder", "folderId", MappedObjectType.Folder, this.rootId, "changetoken") { Guid = Guid.NewGuid() }; var mappedTargetFolder = new MappedObject("target", "targetId", MappedObjectType.Folder, this.rootId, "changetoken") { Guid = Guid.NewGuid() }; this.storage.Setup(s => s.GetObjectByLocalPath(It.Is <IDirectoryInfo>(d => d.Equals(localTargetFolder.Object)))).Returns(mappedTargetFolder); this.storage.Setup(s => s.GetObjectByRemoteId("folderId")).Returns(mappedFolder); remoteFolder.Setup(f => f.Move(this.remoteRootFolder.Object, remoteTargetFolder.Object)).Callback(() => { remoteFolder.Setup(r => r.ChangeToken).Returns("new ChangeToken"); }).Returns(remoteFolder.Object); this.underTest.Solve(localFolder.Object, remoteFolder.Object); remoteFolder.Verify(f => f.Move(this.remoteRootFolder.Object, remoteTargetFolder.Object), Times.Once()); remoteFolder.VerifyUpdateLastModificationDate(localFolder.Object.LastWriteTimeUtc); this.storage.VerifySavedMappedObject(MappedObjectType.Folder, "folderId", "folder", "targetId", "new ChangeToken", true); }
public void PermissionDeniedLeadsToNoOperation() { var remoteFolder = MockOfIFolderUtil.CreateRemoteFolderMock("folderId", "folder", "/folder", this.rootId); var remoteTargetFolder = MockOfIFolderUtil.CreateRemoteFolderMock("targetId", "target", "/target", this.rootId); this.session.AddRemoteObjects(remoteFolder.Object, remoteTargetFolder.Object); var localTargetFolder = MockOfIFileSystemInfoFactoryUtil.CreateLocalFolder(Path.Combine(Path.GetTempPath(), "target")); var localFolder = MockOfIFileSystemInfoFactoryUtil.CreateLocalFolder(Path.Combine(Path.GetTempPath(), "target", "folder")); localFolder.Setup(f => f.Parent).Returns(localTargetFolder.Object); var mappedFolder = new MappedObject("folder", "folderId", MappedObjectType.Folder, this.rootId, "changetoken") { Guid = Guid.NewGuid() }; var mappedTargetFolder = new MappedObject("target", "targetId", MappedObjectType.Folder, this.rootId, "changetoken") { Guid = Guid.NewGuid() }; this.storage.Setup(s => s.GetObjectByLocalPath(It.Is <IDirectoryInfo>(d => d.Equals(localTargetFolder.Object)))).Returns(mappedTargetFolder); this.storage.Setup(s => s.GetObjectByRemoteId("folderId")).Returns(mappedFolder); remoteFolder.Setup(f => f.Move(this.remoteRootFolder.Object, remoteTargetFolder.Object)).Throws(new CmisPermissionDeniedException()); this.underTest.Solve(localFolder.Object, remoteFolder.Object); remoteFolder.Verify(f => f.Move(this.remoteRootFolder.Object, remoteTargetFolder.Object), Times.Once()); this.storage.VerifyThatNoObjectIsManipulated(); }
public void Utf8CharacterLeadsToNoSavings() { string newFolderName = @"ä".Normalize(System.Text.NormalizationForm.FormD); var remoteFolder = MockOfIFolderUtil.CreateRemoteFolderMock("folderId", "folder", "/folder", this.rootId); var targetFolder = MockOfIFolderUtil.CreateRemoteFolderMock("targetId", "target", "/target", this.rootId); this.session.AddRemoteObjects(remoteFolder.Object, targetFolder.Object); var localTargetFolder = MockOfIFileSystemInfoFactoryUtil.CreateLocalFolder(Path.Combine(Path.GetTempPath(), "target")); var localFolder = MockOfIFileSystemInfoFactoryUtil.CreateLocalFolder(Path.Combine(Path.GetTempPath(), "target", newFolderName)); localFolder.Setup(f => f.Parent).Returns(localTargetFolder.Object); var mappedFolder = new MappedObject("folder", "folderId", MappedObjectType.Folder, this.rootId, "changetoken") { Guid = Guid.NewGuid() }; var mappedTargetFolder = new MappedObject("target", "targetId", MappedObjectType.Folder, this.rootId, "changetoken") { Guid = Guid.NewGuid() }; this.storage.Setup(s => s.GetObjectByLocalPath(It.Is <IDirectoryInfo>(d => d.Equals(localTargetFolder.Object)))).Returns(mappedTargetFolder); this.storage.Setup(s => s.GetObjectByRemoteId("folderId")).Returns(mappedFolder); remoteFolder.Setup(f => f.Move(this.remoteRootFolder.Object, targetFolder.Object)).Returns(remoteFolder.Object); remoteFolder.Setup(f => f.Rename(newFolderName, true)).Throws <CmisConstraintException>(); Assert.Throws <InteractionNeededException>(() => this.underTest.Solve(localFolder.Object, remoteFolder.Object)); remoteFolder.Verify(f => f.Move(this.remoteRootFolder.Object, targetFolder.Object), Times.Once()); remoteFolder.Verify(f => f.Rename(newFolderName, true), Times.Once()); remoteFolder.Verify(f => f.UpdateProperties(It.IsAny <System.Collections.Generic.IDictionary <string, object> >()), Times.Never()); this.storage.VerifyThatNoObjectIsManipulated(); }
public void SetUp() { this.storage = new Mock <IMetaDataStorage>(); this.session = new Mock <ISession>(); this.remoteRootFolder = MockOfIFolderUtil.CreateRemoteFolderMock(this.rootId, "/", "/", null); this.session.AddRemoteObject(this.remoteRootFolder.Object); this.localRootFolder = MockOfIFileSystemInfoFactoryUtil.CreateLocalFolder(Path.GetTempPath()); this.mappedRootFolder = new MappedObject("/", this.rootId, MappedObjectType.Folder, null, "changeToken") { Guid = Guid.NewGuid() }; this.storage.Setup(s => s.GetObjectByLocalPath(It.Is <IDirectoryInfo>(d => d.Equals(this.localRootFolder.Object)))).Returns(this.mappedRootFolder); this.underTest = new LocalObjectMoved(this.session.Object, this.storage.Object, true); }