Пример #1
0
        public void TestRemoveAtOutOfRange()
        {
            YogaNode parent = new YogaNode();
            YogaNode child  = new YogaNode();

            parent.Insert(0, child);
            Assert.Throws <ArgumentOutOfRangeException>(() => parent.RemoveAt(1));
        }
Пример #2
0
        public void TestAddChildGetParent()
        {
            YogaNode parent = new YogaNode();
            YogaNode child  = new YogaNode();

            Assert.IsNull(child.Parent);
            Assert.AreEqual(0, parent.Count);

            parent.Insert(0, child);

            Assert.AreEqual(1, parent.Count);
            Assert.AreEqual(child, parent[0]);
            Assert.AreEqual(parent, child.Parent);

            parent.RemoveAt(0);

            Assert.IsNull(child.Parent);
            Assert.AreEqual(0, parent.Count);
        }
Пример #3
0
        public void TestChildren()
        {
            YogaNode parent = new YogaNode();

            foreach (YogaNode node in parent)
            {
                Assert.Fail(node.ToString());
            }

            YogaNode child0 = new YogaNode();

            Assert.AreEqual(-1, parent.IndexOf(child0));
            parent.Insert(0, child0);
            foreach (YogaNode node in parent)
            {
                Assert.AreEqual(0, parent.IndexOf(node));
            }

            YogaNode child1 = new YogaNode();

            parent.Insert(1, child1);
            int index = 0;

            foreach (YogaNode node in parent)
            {
                Assert.AreEqual(index++, parent.IndexOf(node));
            }

            parent.RemoveAt(0);
            Assert.AreEqual(-1, parent.IndexOf(child0));
            Assert.AreEqual(0, parent.IndexOf(child1));

            parent.Clear();
            Assert.AreEqual(0, parent.Count);

            parent.Clear();
            Assert.AreEqual(0, parent.Count);
        }
Пример #4
0
        public void TestRemoveAtFromEmpty()
        {
            YogaNode parent = new YogaNode();

            Assert.Throws <ArgumentOutOfRangeException>(() => parent.RemoveAt(0));
        }