Esempio n. 1
0
        public void ModelUndo()
        {
            var compound = new NbtCompound();

            //compound.Add(new NbtByte("test"));
            //Assert.AreEqual(compound.Count, 1);
            //model.UndoHistory.Undo();
            //Assert.AreEqual(compound.Count, 0);

            var sub = new NbtCompound("test");
            var b1  = new NbtByte("b1");
            var b2  = new NbtByte("b2");

            compound.Add(sub);
            sub.Add(b1);
            sub.Add(b2);

            var model = new NbtTreeModel();
            var node  = new NbtTagNode(model, null, compound);

            model.Import(node);

            model.UndoHistory.StartBatchOperation();
            node.ReceiveDrop(new[] { node.Children.First() }, 0);
            model.UndoHistory.FinishBatchOperation(new DescriptionHolder(""), true);

            model.UndoHistory.StartBatchOperation();
            node.Children.First().ReceiveDrop(new[] { node.Children.First().Children.First() }, 0);
            model.UndoHistory.FinishBatchOperation(new DescriptionHolder(""), true);

            model.UndoHistory.Undo();
        }
Esempio n. 2
0
        public void Parenting()
        {
            var compound = new NbtCompound("root")
            {
                new NbtByte("sub1"),
                new NbtShort("sub2"),
                new NbtCompound("sub3")
                {
                    new NbtString("grandchild", "")
                }
            };
            var root = new NbtTagNode(new NbtTreeModel(), null, compound);

            AssertChildStructure(root);
        }
Esempio n. 3
0
        public void ChildrenRefresh()
        {
            var compound = new NbtCompound("root")
            {
                new NbtByte("sub1"),
                new NbtShort("sub2"),
                new NbtCompound("sub3")
                {
                    new NbtString("grandchild", "")
                }
            };
            var root = new NbtTagNode(new NbtTreeModel(), null, compound);

            Assert.AreEqual(root.Children.Count(), 3);
            compound.Add(new NbtInt("more1"));
            compound.Add(new NbtInt("more2"));
            compound.Add(new NbtInt("more3"));
            Assert.AreEqual(root.Children.Count(), 6);
            compound.Remove("more1");
            Assert.AreEqual(root.Children.Count(), 5);
        }