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));
        }
 public void MoveBogusIdxTest()
 {
     //attempt to move to a bogus idx at a parent
     //That is not permitted
     GenericDocument doc = new GenericDocument(_parent, "Foo", "text/plain");
     GenericFolder folder2 = new GenericFolder(_parent, "Folder2");
     doc.Move(folder2, 10);
 }
 public void MoveBogusIdxTest()
 {
     //attempt to move to a bogus idx at a parent
     //That is not permitted
     GenericContentContainer contain = new GenericContentContainer(_doc);
     GenericDocument doc2 = new GenericDocument(_parent, "Doc1", "text/plain");
     contain.Move(doc2, 10);
 }
        public void CarveOutEmptyListTest()
        {
            //When the list is empty, any attempt to carve out of it with a non-zero
            //length will fail
            GenericDocument doc2 = new GenericDocument(_parent,  "Baz",  "text/plain");

            _cont.Children.CarveOut(doc2,
                                    0,
                                    0,
                                    1);
        }
        public void AncestryTest()
        {
            GenericDocument doc1 = new GenericDocument(_parent, "Doc1", "text/plain");
            GenericDocument doc2 = new GenericDocument(_parent, "Doc2", "text/plain");
            GenericContentContainer contain = new GenericContentContainer(doc1);

            //The root folder is the ancestor of everyone
            Assert.IsTrue(_root.IsAncestorOf(contain.FileSystemParent));

            //And everyone is the descendent of the root folder
            Assert.IsTrue(contain.FileSystemParent.IsDescendentOf(_root));
        }
        public void CarveOutBadDestIdxTest()
        {
            //Pass an invalid index into the dest list
            GenericDocument doc2 = new GenericDocument(_parent,  "Baz",  "text/plain");
            GenericContentObject obj1 = new GenericContentObject(_cont);
            GenericContentObject obj2 = new GenericContentObject(_cont);
            GenericContentObject obj3 = new GenericContentObject(_cont);
            GenericContentObject obj4 = new GenericContentObject(_cont);

            _cont.Children.CarveOut(doc2,
                                    10,
                                    0,
                                    1);
        }
        public void GenericEmptyTest()
        {
            GenericDocument doc = new GenericDocument(_parent, "Foo", "text/plain");

            Assert.AreEqual(1, _parent.Children.Count);
            Assert.IsTrue(doc.IsDescendentOf(_parent));
            Assert.IsTrue(doc.IsDescendentOf(_root));
            Assert.AreEqual("Foo", doc.Name);
            Assert.AreEqual("text/plain", doc.MimeType);
            Assert.AreEqual(_parent.Path + Path.DirectorySeparatorChar.ToString() + doc.Name, doc.Path);
            Assert.AreEqual(_parent, doc.Parent);
            Assert.AreEqual(_parent, doc.ParentFolder);
            Assert.AreEqual(_parent, doc.FileSystemParent);
            Assert.AreEqual(_root, doc.ParentFolder.RootFolder);
        }
        public void MoveTest()
        {
            GenericDocument doc1 = new GenericDocument(_parent, "Doc1", "text/plain");
            GenericDocument doc2 = new GenericDocument(_parent, "Doc2", "text/plain");
            GenericContentContainer contain = new GenericContentContainer(doc1);
            GenericContentObject obj = new GenericContentObject(contain);

            Assert.AreEqual(1, doc1.Children.Count);
            Assert.AreEqual(1, contain.Children.Count);
            Assert.AreEqual(0, doc2.Children.Count);

            Assert.AreEqual(contain, obj.Parent);
            Assert.AreEqual(doc1, obj.FileSystemParent);
            Assert.AreEqual(doc1, contain.Parent);

            //Move obj from doc1 to doc2
            contain.Move(doc2);
            Assert.AreEqual(0, doc1.Children.Count);
            Assert.AreEqual(1, doc2.Children.Count);

            Assert.AreEqual(contain, obj.Parent);
            Assert.AreEqual(doc2, obj.FileSystemParent);
            Assert.AreEqual(doc2, contain.Parent);
        }
 public void MoveNonFolderTest()
 {
     //attempt to move to an object that isn't a folder
     //That is not permitted
     GenericDocument doc = new GenericDocument(_parent, "Foo", "text/plain");
     GenericDocument doc2 = new GenericDocument(_parent, "Foo", "text/plain");
     GenericContentContainer notMine = new GenericContentContainer(doc2);
     doc.Move(notMine);
 }
Beispiel #10
0
 public void NullParentTest()
 {
     GenericDocument doc = new GenericDocument(null, "Foo", "text/plain");
 }
Beispiel #11
0
 public void NullMimeTypeTest()
 {
     GenericDocument doc = new GenericDocument(_parent, "Foo", null);
 }
Beispiel #12
0
        public void NullIsDescendentTest()
        {
            GenericDocument doc = new GenericDocument(_parent, "Foo", "text/plain");

            //Can't pass null to IsDescendentOf
            doc.IsDescendentOf(null);
        }
Beispiel #13
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);
        }
Beispiel #14
0
 public void MoveNullTest()
 {
     //attempt to move to a null folder
     //That is not permitted
     GenericDocument doc = new GenericDocument(_parent, "Foo", "text/plain");
     doc.Move(null);
 }
        public void CarveOutEntireListTest()
        {
            //Carve out the entire contents of the source list into the destination
            GenericDocument doc2 = new GenericDocument(_parent,  "Baz",  "text/plain");
            GenericContentObject obj1 = new GenericContentObject(_cont);
            GenericContentObject obj2 = new GenericContentObject(_cont);
            GenericContentObject obj3 = new GenericContentObject(_cont);
            GenericContentObject obj4 = new GenericContentObject(_cont);

            _cont.Children.CarveOut(doc2,
                                    0,
                                    0,
                                    _cont.Children.Count);

            Assert.AreEqual(0,  _cont.Children.Count);
            Assert.AreEqual(4,  doc2.Children.Count);
            foreach (IContentObject obj in doc2.Children) {
                Assert.AreEqual(doc2,  obj.Parent);
            }
        }
        public void MoveTest()
        {
            GenericDocument doc1 = new GenericDocument(_parent, "Doc1", "text/plain");
            GenericDocument doc2 = new GenericDocument(_parent, "Doc2", "text/plain");
            GenericContentContainer contain = new GenericContentContainer(doc1);

            Assert.AreEqual(1, doc1.Children.Count);
            Assert.AreEqual(0, doc2.Children.Count);

            Assert.AreEqual(doc1, contain.Parent);
            Assert.AreEqual(doc1, contain.FileSystemParent);

            //Move obj from doc1 to doc2
            contain.Changed += new ContentObjectChangedEventHandler(contain_Changed);
            contain.Move(doc2);
            contain.Changed -= new ContentObjectChangedEventHandler(contain_Changed);
            Assert.AreEqual(true, contain.PropertyBag["contain_Changed.fired"]);
            Assert.AreEqual(0, doc1.Children.Count);
            Assert.AreEqual(1, doc2.Children.Count);

            Assert.AreEqual(doc2, contain.Parent);
            Assert.AreEqual(doc2, contain.FileSystemParent);
        }
Beispiel #17
0
 public void NullNameTest()
 {
     GenericDocument doc = new GenericDocument(_parent, null, "text/plain");
 }