Inheritance: IMappedObject
 public void SetUp() {
     this.storage = new Mock<IMetaDataStorage>();
     this.session = new Mock<ISession>();
     this.session.SetupTypeSystem();
     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);
 }
 public void RenameFolder([Values(true, false)]bool childrenAreIgnored) {
     this.SetUpMocks();
     var dir = Mock.Of<IDirectoryInfo>(
         f =>
         f.Name == "newName");
     var folder = MockOfIFolderUtil.CreateRemoteFolderMock("remoteId", "oldName", "path", ignored: childrenAreIgnored);
     var obj = new MappedObject("oldName", "remoteId", MappedObjectType.Folder, "parentId", "changeToken") { Guid = Guid.NewGuid() };
     this.storage.AddMappedFolder(obj);
     this.underTest.Solve(dir, folder.Object, ContentChangeType.NONE, ContentChangeType.NONE);
     folder.Verify(f => f.Rename("newName", true), Times.Once());
     this.storage.VerifySavedMappedObject(MappedObjectType.Folder, "remoteId", "newName", "parentId", "changeToken", ignored: childrenAreIgnored);
     this.changeSolver.Verify(s => s.Solve(dir, folder.Object, ContentChangeType.NONE, ContentChangeType.NONE));
 }
 public void ConstructorSetsDefaultParamsToNull([Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
     var obj = new MappedObject("name", "remoteId", type, "parentId", "changeToken");
     Assert.IsNull(obj.ChecksumAlgorithmName);
     Assert.IsNull(obj.Description);
     Assert.IsNull(obj.LastChecksum);
     Assert.IsNull(obj.LastLocalWriteTimeUtc);
     Assert.IsNull(obj.LastRemoteWriteTimeUtc);
     Assert.AreEqual(-1, obj.LastContentSize);
     Assert.That(obj.Ignored, Is.False);
     Assert.That(obj.ActualOperation, Is.EqualTo(OperationType.No));
     Assert.That(obj.Retries, Is.Empty);
     Assert.That(obj.IsReadOnly, Is.False);
     Assert.That(obj.LastTimeStoredInStorage, Is.Null);
 }
 public void MoveAndRenameLocalFolder([Values(true, false)]bool childrenAreIgnored) {
     this.SetUpMocks();
     string oldPath = Path.Combine(Path.GetTempPath(), "old", "oldname");
     string newPath = Path.Combine(Path.GetTempPath(), "new", "newname");
     var mappedObject = new MappedObject("oldname", "remoteId", MappedObjectType.Folder, "oldParentId", "changeToken") { Guid = Guid.NewGuid() };
     this.storage.AddMappedFolder(mappedObject);
     var remoteFolder = MockOfIFolderUtil.CreateRemoteFolderMock("remoteId", "newname", "path", "parentId", ignored: childrenAreIgnored);
     var dir = Mock.Of<IDirectoryInfo>(
         d =>
         d.FullName == oldPath);
     this.storage.Setup(s => s.Matcher.CreateLocalPath(remoteFolder.Object)).Returns(newPath);
     this.underTest.Solve(dir, remoteFolder.Object, ContentChangeType.NONE, ContentChangeType.NONE);
     Mock.Get(dir).Verify(d => d.MoveTo(newPath), Times.Once());
     this.changeSolver.Verify(s => s.Solve(dir, remoteFolder.Object, ContentChangeType.NONE, ContentChangeType.NONE), Times.Once());
     this.storage.VerifySavedMappedObject(MappedObjectType.Folder, "remoteId", "newname", "parentId", "changeToken", ignored: childrenAreIgnored);
 }
 public void RenameFile() {
     this.SetUpMocks();
     long fileLength = 100;
     var file = Mock.Of<IFileInfo>(
         f =>
         f.Name == "newName");
     var doc = Mock.Of<IDocument>(
         d =>
         d.Id == "remoteId");
     var obj = new MappedObject("oldName", "remoteId", MappedObjectType.File, "parentId", "changeToken", fileLength) { Guid = Guid.NewGuid() };
     this.storage.AddMappedFile(obj);
     this.underTest.Solve(file, doc, ContentChangeType.CHANGED, ContentChangeType.CHANGED);
     Mock.Get(doc).Verify(d => d.Rename("newName", true), Times.Once());
     this.storage.VerifySavedMappedObject(MappedObjectType.File, "remoteId", "newName", "parentId", "changeToken", contentSize: fileLength);
     this.changeSolver.Verify(s => s.Solve(file, doc, ContentChangeType.CHANGED, ContentChangeType.CHANGED));
 }
 public void HandlesFolderEventAndPassesArgumentsToSecondSolverAfterDbModification() {
     var mappedObject = new MappedObject("oldName", "remoteId", MappedObjectType.Folder, "parentId", "changeToken") {
         Guid = Guid.NewGuid()
     };
     this.storage.AddMappedFolder(mappedObject);
     var folder = Mock.Of<IDirectoryInfo>(
         f =>
         f.Name == "newName" &&
         f.Uuid == mappedObject.Guid &&
         f.FullName == "<path to folder>" &&
         f.GetFiles() == new IFileInfo[0] &&
         f.GetDirectories() == new IDirectoryInfo[0]);
     this.underTest.Solve(folder, null, ContentChangeType.NONE, ContentChangeType.NONE);
     this.storage.Verify(s => s.RemoveObject(mappedObject));
     this.secondSolver.Verify(s => s.Solve(folder, null, ContentChangeType.NONE, ContentChangeType.NONE));
 }
        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 ConstructorTakesData(
            [Values(true, false)]bool ignored,
            [Values(true, false)]bool readOnly,
            [Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type)
        {
            var data = new MappedObject("name", "remoteId", type, "parentId", "changeToken") {
                LastChecksum = new byte[20],
                Ignored = ignored,
                Guid = Guid.NewGuid(),
                LastLocalWriteTimeUtc = DateTime.Now,
                LastRemoteWriteTimeUtc = DateTime.UtcNow,
                Description = "desc",
                LastContentSize = type == MappedObjectType.File ? 2345 : 0,
                IsReadOnly = readOnly,
                LastTimeStoredInStorage = DateTime.UtcNow
            };

            var file = new MappedObject(data);

            Assert.That(data, Is.EqualTo(file));
            Assert.That(file.LastTimeStoredInStorage, Is.EqualTo(data.LastTimeStoredInStorage));
        }
 public void SetUp() {
     this.newParentPath = Path.Combine(Path.GetTempPath(), this.newParentName);
     this.oldParentUuid = Guid.NewGuid();
     this.newParentUuid = Guid.NewGuid();
     this.localUuid = Guid.NewGuid();
     this.session = new Mock<ISession>();
     this.session.SetupTypeSystem();
     this.storage = new Mock<IMetaDataStorage>();
     this.oldLocalParentFolder = new Mock<IDirectoryInfo>();
     this.oldLocalParentFolder.SetupGuid(this.oldParentUuid);
     this.mappedParent = new MappedObject("parent", this.oldRemoteParentId, MappedObjectType.Folder, null, this.oldChangeToken) {
         Guid = this.oldParentUuid
     };
     this.storage.AddMappedFolder(this.mappedParent);
     this.underTest = new LocalObjectMovedRemoteObjectMoved(this.session.Object, this.storage.Object);
     var mappedNewLocalParent = new MappedObject(this.newParentName, this.newRemoteParentId, MappedObjectType.Folder, null, this.oldChangeToken) {
         Guid = this.newParentUuid
     };
     this.storage.AddMappedFolder(mappedNewLocalParent);
     this.localModification = DateTime.UtcNow;
     this.remoteModification = this.localModification;
     this.oldModification = this.localModification - TimeSpan.FromDays(1);
 }
 public void RenameFile()
 {
     this.SetUpMocks();
     long fileLength = 100;
     string oldPath = Path.Combine(Path.GetTempPath(), "oldname");
     string newPath = Path.Combine(Path.GetTempPath(), "newname");
     var mappedObject = new MappedObject("oldname", "remoteId", MappedObjectType.File, "parentId", "changeToken", fileLength) { Guid = Guid.NewGuid() };
     this.storage.AddMappedFolder(mappedObject);
     var remoteFolder = Mock.Of<IDocument>(
         f =>
         f.Id == "remoteId" &&
         f.Name == "newname" &&
         f.Parents[0].Id == "parentId");
     var dir = Mock.Of<IFileInfo>(
         d =>
         d.FullName == oldPath &&
         d.Directory.FullName == Path.GetTempPath());
     this.storage.Setup(s => s.Matcher.CreateLocalPath(remoteFolder)).Returns(newPath);
     this.underTest.Solve(dir, remoteFolder, ContentChangeType.NONE, ContentChangeType.NONE);
     Mock.Get(dir).Verify(d => d.MoveTo(newPath), Times.Once());
     this.changeSolver.Verify(s => s.Solve(dir, remoteFolder, ContentChangeType.NONE, ContentChangeType.NONE), Times.Once());
     this.storage.VerifySavedMappedObject(MappedObjectType.File, "remoteId", "newname", "parentId", "changeToken", contentSize: fileLength);
 }
Esempio n. 11
0
 public void LastTimeStoredPropertyIsIrrelevantForEquality([Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
     var obj1 = new MappedObject("name", "id", type, null, null) { LastTimeStoredInStorage = DateTime.UtcNow };
     var obj2 = new MappedObject("name", "id", type, null, null);
     Assert.That(obj1, Is.EqualTo(obj2));
 }
Esempio n. 12
0
 public void LastTimeStoredInStorageProperty([Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
     var date = DateTime.Now;
     var underTest = new MappedObject("name", "id", type, null, null) {
         LastTimeStoredInStorage = date
     };
     Assert.That(underTest.LastTimeStoredInStorage, Is.EqualTo(date));
 }
Esempio n. 13
0
 public void RetriesDictionaryProperty() {
     var dict = new Dictionary<OperationType, int>();
     dict.Add(OperationType.Download, 1);
     var obj = new MappedObject("name", "id", MappedObjectType.File, null, null) { Retries = dict };
     Assert.That(obj.Retries, Is.EqualTo(dict));
     Assert.That(obj.Retries[OperationType.Download], Is.EqualTo(1));
 }
Esempio n. 14
0
 public void ReadOnlyProperty([Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
     var obj = new MappedObject("name", "id", type, null, null) { IsReadOnly = true };
     Assert.That(obj.IsReadOnly, Is.True);
 }
Esempio n. 15
0
 public void IgnoredProperty([Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
     var obj = new MappedObject("name", "id", type, null, null) { Ignored = true };
     Assert.That(obj.Ignored, Is.True);
 }
Esempio n. 16
0
        public void DescriptionProperty([Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
            var file = new MappedObject("name", "remoteId", type, null, null) { Description = "desc" };
            Assert.AreEqual("desc", file.Description);

            file.Description = "other desc";
            Assert.AreEqual("other desc", file.Description);
        }
 private void SetupOldMappedObject(bool isFolder) {
     var mappedObject = new MappedObject(
         this.oldName,
         this.remoteObjectId,
         isFolder ? MappedObjectType.Folder : MappedObjectType.File,
         this.oldRemoteParentId,
         this.oldChangeToken) {
         Guid = this.localUuid,
         LastLocalWriteTimeUtc = this.oldModification,
         LastRemoteWriteTimeUtc = this.oldModification,
         LastContentSize = isFolder ? -1 : 0
     };
     if (isFolder) {
         this.storage.AddMappedFolder(mappedObject);
     } else {
         this.storage.AddMappedFile(mappedObject);
     }
 }
        public void GetObjectByGuidReturnsSavedObject([Values(true, false)]bool withValidation) {
            var storage = new MetaDataStorage(this.engine, Mock.Of<IPathMatcher>(), withValidation);
            var uuid = Guid.NewGuid();
            var file = new MappedObject("name" , "rootId", MappedObjectType.File, null, "token") { Guid = uuid };
            storage.SaveMappedObject(file);

            Assert.That(storage.GetObjectByGuid(uuid), Is.EqualTo(file));
        }
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MappedObject"/> class.
 /// </summary>
 /// <param name='data'>
 /// Data to copy.
 /// </param>
 public MappedObject(MappedObject data) {
     if (data != null) {
         this.ParentId = data.ParentId;
         this.Description = data.Description;
         this.ChecksumAlgorithmName = data.ChecksumAlgorithmName;
         this.Guid = data.Guid;
         this.LastChangeToken = data.LastChangeToken;
         this.LastLocalWriteTimeUtc = data.LastLocalWriteTimeUtc;
         this.LastRemoteWriteTimeUtc = data.LastRemoteWriteTimeUtc;
         this.Name = data.Name;
         this.RemoteObjectId = data.RemoteObjectId;
         this.Type = data.Type;
         this.LastContentSize = data.LastContentSize;
         this.ActualOperation = data.ActualOperation;
         this.Ignored = data.Ignored;
         this.IsReadOnly = data.IsReadOnly;
         this.Retries = data.Retries ?? new Dictionary<OperationType, int>();
         this.LastTimeStoredInStorage = data.LastTimeStoredInStorage;
         if (data.LastChecksum == null) {
             this.LastChecksum = null;
         } else {
             this.LastChecksum = new byte[data.LastChecksum.Length];
             Buffer.BlockCopy(data.LastChecksum, 0, this.LastChecksum, 0, data.LastChecksum.Length);
         }
     }
 }
        public void GetObjectTreeReturnsOneItemWithEmptyChildrenList([Values(true, false)]bool withValidation) {
            var storage = new MetaDataStorage(this.engine, Mock.Of<IPathMatcher>(), withValidation);
            var rootFolder = new MappedObject("name", "rootId", MappedObjectType.Folder, null, "token");
            storage.SaveMappedObject(rootFolder);

            var tree = storage.GetObjectTree();
            Assert.That(tree.Item, Is.EqualTo(rootFolder));
            Assert.That(tree.Children, Is.Empty);
        }
        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 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();
        }
Esempio n. 23
0
 public void IFolderConstructor() {
     string folderName = "a";
     string path = Path.Combine(Path.GetTempPath(), folderName);
     string id = "id";
     string parentId = "papa";
     string lastChangeToken = "token";
     Mock<IFolder> remoteObject = MockOfIFolderUtil.CreateRemoteFolderMock(id, folderName, path, parentId, lastChangeToken);
     MappedObject mappedObject = new MappedObject(remoteObject.Object);
     Assert.That(mappedObject.RemoteObjectId, Is.EqualTo(id), "RemoteObjectId incorrect");
     Assert.That(mappedObject.Name, Is.EqualTo(folderName), "Name incorrect");
     Assert.That(mappedObject.ParentId, Is.EqualTo(parentId), "ParentId incorrect");
     Assert.That(mappedObject.LastChangeToken, Is.EqualTo(lastChangeToken), "LastChangeToken incorrect");
     Assert.That(mappedObject.Type, Is.EqualTo(MappedObjectType.Folder), "Type incorrect");
 }
 public void ThrowOnDublicateGuid([Values(true, false)]bool withValidation) {
     var storage = new MetaDataStorage(this.engine, Mock.Of<IPathMatcher>(), withValidation);
     var rootFolder = new MappedObject("name", "rootId", MappedObjectType.Folder, null, "token");
     var child1 = new MappedObject("sub1", "subId1", MappedObjectType.File, "rootId", "token");
     child1.Guid = Guid.NewGuid();
     var child2 = new MappedObject("sub2", "subId2", MappedObjectType.File, "rootId", "token");
     child2.Guid = child1.Guid;
     storage.SaveMappedObject(rootFolder);
     storage.SaveMappedObject(child1);
     Assert.Throws<DublicateGuidException>(() => storage.SaveMappedObject(child2));
 }
Esempio n. 25
0
 public void ConstructorTakesChangeLogToken([Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
     var obj = new MappedObject("name", "id", type, "parentId", "changes");
     Assert.That(obj.LastChangeToken, Is.EqualTo("changes"));
 }
Esempio n. 26
0
 public void InsertAndSelectMappedObjectData() {
     using (var tran = this.engine.GetTransaction()) {
         string key = "key";
         string name = "name";
         var file = new MappedObject(name, key, MappedObjectType.File, null, null);
         tran.Insert<string, DbCustomSerializer<MappedObject>>("objects", key, file);
         Assert.That((tran.Select<string, DbCustomSerializer<MappedObject>>("objects", key).Value.Get as MappedObject).Equals(file));
     }
 }
Esempio n. 27
0
 public void ConstructorTakesRemoteId([Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
     var obj = new MappedObject("name", "remoteId", type, null, null);
     Assert.That(obj.RemoteObjectId, Is.EqualTo("remoteId"));
 }
Esempio n. 28
0
        public void HashAlgorithmProperty() {
            var file = new MappedObject("name", "remoteId", MappedObjectType.File, null, null) { ChecksumAlgorithmName = "MD5" };
            Assert.AreEqual("MD5", file.ChecksumAlgorithmName);

            file.ChecksumAlgorithmName = "SHA-1";
            Assert.AreEqual("SHA-1", file.ChecksumAlgorithmName);
        }
Esempio n. 29
0
 public void ConstructorTakesParentId(
     [Values("parentId", null)]string parentId,
     [Values(MappedObjectType.File, MappedObjectType.Folder)]MappedObjectType type) {
     var obj = new MappedObject("name", "id", type, parentId, null);
     Assert.That(obj.ParentId, Is.EqualTo(parentId));
 }
        public void GetObjectTreeReturnsTreeEqualToFolderStructure([Values(true, false)]bool withValidation) {
            var storage = new MetaDataStorage(this.engine, Mock.Of<IPathMatcher>(), withValidation);
            var rootFolder = new MappedObject("name", "rootId", MappedObjectType.Folder, null, "token");
            var child1Folder = new MappedObject("sub1", "subId1", MappedObjectType.Folder, "rootId", "token");
            var child2File = new MappedObject("sub2", "subId2", MappedObjectType.File, "subId1", "token");
            storage.SaveMappedObject(rootFolder);
            storage.SaveMappedObject(child1Folder);
            storage.SaveMappedObject(child2File);

            var tree = storage.GetObjectTree();

            Assert.That(tree.Item, Is.EqualTo(rootFolder));
            Assert.That(tree.Children.Count, Is.EqualTo(1));
            Assert.That(tree.Children[0].Item, Is.EqualTo(child1Folder));
            Assert.That(tree.Children[0].Children.Count, Is.EqualTo(1));
            Assert.That(tree.Children[0].Children[0].Item, Is.EqualTo(child2File));
        }