Пример #1
0
        public void NonFsoChildTest()
        {
            GenericRootFolder root = new GenericRootFolder("Foo", ContentModelMockObjectFactory.CreateObjectPersistor());

            //Attempt to add a non-IFileSystemObject child
            GenericContentObject co = new GenericContentObject(root);
        }
Пример #2
0
        public void AncestryTest()
        {
            GenericRootFolder root = new GenericRootFolder("Foo", ContentModelMockObjectFactory.CreateObjectPersistor());
            GenericFolder folder1 = new GenericFolder(root, "Folder1");
            GenericFolder folder2 = new GenericFolder(root, "Folder2");
            GenericFolder folder3 = new GenericFolder(folder2, "Folder3");
            GenericDocument doc1 = new GenericDocument(folder1, "Doc1", "text/plain");
            GenericDocument doc2 = new GenericDocument(folder3, "Doc2", "text/plain");

            //The root folder is the ancestor of everyone
            Assert.IsTrue(root.IsAncestorOf(doc1));
            Assert.IsTrue(root.IsAncestorOf(doc2));

            //And everyone is the descendent of the root folder
            Assert.IsTrue(doc1.IsDescendentOf(root));
            Assert.IsTrue(doc2.IsDescendentOf(root));

            //doc1 is a descendent of folder1
            Assert.IsTrue(doc1.IsDescendentOf(folder1));
            Assert.IsFalse(doc1.IsDescendentOf(folder2));
            Assert.IsFalse(doc1.IsDescendentOf(folder3));

            //doc2 is a descendent of folder2 and folder3
            Assert.IsFalse(doc2.IsDescendentOf(folder1));
            Assert.IsTrue(doc2.IsDescendentOf(folder2));
            Assert.IsTrue(doc2.IsDescendentOf(folder3));
        }
Пример #3
0
        public void MoveTest()
        {
            //attempt to move a root folder to another container.
            //That is not permitted
            GenericRootFolder root = new GenericRootFolder("Foo", ContentModelMockObjectFactory.CreateObjectPersistor());
            GenericRootFolder root2 = new GenericRootFolder("Bar", ContentModelMockObjectFactory.CreateObjectPersistor());

            root.Move(root2);
        }
Пример #4
0
        public void EmptyTest()
        {
            GenericRootFolder root = new GenericRootFolder("Foo", ContentModelMockObjectFactory.CreateObjectPersistor());

            Assert.AreEqual(0, root.Children.Count);
            Assert.IsFalse(root.IsAncestorOf(root));
            Assert.IsFalse(root.IsDescendentOf(root));
            Assert.AreEqual(Path.DirectorySeparatorChar.ToString(), root.Name);
            Assert.AreEqual(Path.DirectorySeparatorChar.ToString(), root.Path);
            Assert.IsNull(root.Parent);
            Assert.IsNull(root.ParentFolder);
            Assert.IsNull(root.FileSystemParent);
            Assert.AreEqual(root, root.RootFolder);
            Assert.AreEqual("Foo", root.Source);
        }
Пример #5
0
        private void LoadRootFolder(String path)
        {
            //Creates a IRootFolder for this folder, and populates it with all child objects
            _logger.Info("LogMsg.LoadingRootFolder", path);

            IRootFolder root = new GenericRootFolder("[root]", _store);

            Object txn = _store.BeginTransaction();

            _store.Add(root);

            LoadFolderInt(root, path);

            //Update to reflect the new contents
            _store.Update(root);

            _store.CommitTransaction(txn);
        }
Пример #6
0
        public void MoveTest()
        {
            GenericRootFolder root = new GenericRootFolder("Foo", ContentModelMockObjectFactory.CreateObjectPersistor());
            GenericFolder folder1 = new GenericFolder(root, "Folder1");
            GenericFolder folder2 = new GenericFolder(root, "Folder2");
            GenericFolder folder3 = new GenericFolder(folder2, "Folder3");
            GenericDocument doc1 = new GenericDocument(folder1, "Doc1", "text/plain");
            GenericDocument doc2 = new GenericDocument(folder3, "Doc2", "text/plain");

            Assert.AreEqual(2, root.Children.Count);
            Assert.AreEqual(1, folder1.Children.Count);
            Assert.AreEqual(1, folder2.Children.Count);
            Assert.AreEqual(1, folder3.Children.Count);

            Assert.AreEqual(root, folder1.ParentFolder);
            Assert.AreEqual(root, folder2.ParentFolder);
            Assert.AreEqual(folder2, folder3.ParentFolder);
            Assert.AreEqual(folder1, doc1.ParentFolder);
            Assert.AreEqual(folder3, doc2.ParentFolder);

            //Move doc2 from folder1 to folder2
            Assert.AreEqual(Path.Combine(folder1.Path, doc1.Name), doc1.Path);
            doc1.Move(folder2);
            Assert.AreEqual(Path.Combine(folder2.Path, doc1.Name), doc1.Path);
            Assert.AreEqual(0, folder1.Children.Count);
            Assert.AreEqual(2, folder2.Children.Count);

            Assert.AreEqual(root, folder1.ParentFolder);
            Assert.AreEqual(root, folder2.ParentFolder);
            Assert.AreEqual(folder2, folder3.ParentFolder);
            Assert.AreEqual(folder2, doc1.ParentFolder);
            Assert.AreEqual(folder3, doc2.ParentFolder);
        }
Пример #7
0
 public void NullSourceTest()
 {
     GenericRootFolder root = new GenericRootFolder(null, ContentModelMockObjectFactory.CreateObjectPersistor());
 }
Пример #8
0
 public void NullPersistorTest()
 {
     GenericRootFolder root = new GenericRootFolder("Foo", null);
 }