Ejemplo n.º 1
0
        public void AddTo_CanBeAddedToNull()
        {
            AnItem parent = new AnItem();
            AnItem child  = new AnItem();

            child.AddTo(parent);
            Assert.AreEqual(parent, child.Parent);
            EnumerableAssert.Contains(parent.Children, child);

            child.AddTo(null);
            Assert.IsNull(child.Parent);
            EnumerableAssert.DoesntContain(parent.Children, child);
        }
Ejemplo n.º 2
0
        public void AddTo_IsRemovedFrom_PreviousParentChildren()
        {
            AnItem parent1 = new AnItem();
            AnItem parent2 = new AnItem();
            AnItem child   = new AnItem();

            child.AddTo(parent1);
            EnumerableAssert.Contains(parent1.Children, child);
            EnumerableAssert.DoesntContain(parent2.Children, child);

            child.AddTo(parent2);
            EnumerableAssert.DoesntContain(parent1.Children, child);
            EnumerableAssert.Contains(parent2.Children, child);
        }
Ejemplo n.º 3
0
        public void AddTo_IsAppendedLast_EvenWhenSortOrder_MayIndicateOtherwise()
        {
            AnItem parent = new AnItem();
            AnItem child1 = new AnItem();

            child1.SortOrder = 4;
            AnItem child2 = new AnItem();

            child2.SortOrder = 3;
            AnItem child3 = new AnItem();

            child3.SortOrder = 2;
            AnItem child4 = new AnItem();

            child4.SortOrder = 1;

            child1.AddTo(parent);
            child2.AddTo(parent);
            child3.AddTo(parent);
            child4.AddTo(parent);

            Assert.AreEqual(child1, parent.Children[0]);
            Assert.AreEqual(child2, parent.Children[1]);
            Assert.AreEqual(child3, parent.Children[2]);
            Assert.AreEqual(child4, parent.Children[3]);
        }
Ejemplo n.º 4
0
        public void AddTo_IsAddedToChildren()
        {
            AnItem parent = new AnItem();
            AnItem child  = new AnItem();

            child.AddTo(parent);
            EnumerableAssert.Contains(parent.Children, child);
        }
Ejemplo n.º 5
0
        public void AddTo_UpdatesParentRelation()
        {
            AnItem parent = new AnItem();
            AnItem child  = new AnItem();

            child.AddTo(parent);
            Assert.AreEqual(parent, child.Parent);
        }
Ejemplo n.º 6
0
        public void AddsToChildrenWhenOnlyParentIsSet()
        {
            AnItem parent = new AnItem();
            AnItem child  = new AnItem();

            child.Parent = parent;

            child.AddTo(parent);
            EnumerableAssert.Contains(parent.Children, child);
        }
Ejemplo n.º 7
0
        public void DoesntAddToChildrenTwice()
        {
            AnItem parent = new AnItem();
            AnItem child  = new AnItem();

            parent.Children.Add(child);

            child.AddTo(parent);
            Assert.AreEqual(parent, child.Parent);
            Assert.AreEqual(1, parent.Children.Count);
        }
Ejemplo n.º 8
0
        public void AddTo_IsAppendedLast()
        {
            AnItem parent = new AnItem();
            AnItem child1 = new AnItem();
            AnItem child2 = new AnItem();
            AnItem child3 = new AnItem();
            AnItem child4 = new AnItem();

            child1.AddTo(parent);
            child2.AddTo(parent);
            child3.AddTo(parent);
            child4.AddTo(parent);

            Assert.AreEqual(child1, parent.Children[0]);
            Assert.AreEqual(child2, parent.Children[1]);
            Assert.AreEqual(child3, parent.Children[2]);
            Assert.AreEqual(child4, parent.Children[3]);
        }