Example #1
0
        public void TestMultipleNestedStruct()
        {
            var obj = new SimpleClassWithNestedStruct(1.0, "test", 5.0, "inner value");

            Assert.That(obj.Struct.FirstValue, Is.EqualTo(1.0));
            Assert.That(obj.Struct.SecondValue, Is.EqualTo("test"));
            Assert.That(obj.Struct.InnerStruct.FirstValue, Is.EqualTo(5.0));
            Assert.That(obj.Struct.InnerStruct.SecondValue, Is.EqualTo("inner value"));

            var        container = new NodeContainer();
            IGraphNode model     = container.GetOrCreateNode(obj);

            Console.WriteLine(model.PrintHierarchy());
            var structNode = model.GetChild("Struct").Content.Reference.AsObject.TargetNode;

            structNode.GetChild("FirstValue").Content.Update(2.0);
            structNode.GetChild("SecondValue").Content.Update("new value");
            structNode = structNode.GetChild("InnerStruct").Content.Reference.AsObject.TargetNode;
            structNode.GetChild("FirstValue").Content.Update(7.0);
            structNode.GetChild("SecondValue").Content.Update("new inner value");

            Assert.That(obj.Struct.FirstValue, Is.EqualTo(2.0));
            Assert.That(obj.Struct.SecondValue, Is.EqualTo("new value"));
            Assert.That(obj.Struct.InnerStruct.FirstValue, Is.EqualTo(7.0));
            Assert.That(obj.Struct.InnerStruct.SecondValue, Is.EqualTo("new inner value"));
        }
Example #2
0
        public void TestPrimitiveItemUpdate()
        {
            var        obj       = new ClassWithLists();
            var        container = new NodeContainer();
            IGraphNode model     = container.GetOrCreateNode(obj);

            Console.WriteLine(model.PrintHierarchy());
            ((List <int>)model.GetChild("IntList").Content.Value)[1] = 42;
            ((List <int>)model.GetChild("IntList").Content.Value).Add(26);
            Assert.That(obj.IntList.Count, Is.EqualTo(4));
            Assert.That(obj.IntList[1], Is.EqualTo(42));
            Assert.That(obj.IntList[3], Is.EqualTo(26));
            Helper.ConsistencyCheck(container, obj);
        }
Example #3
0
        public static void PrintModelContainerContent(NodeContainer container, IGraphNode rootNode = null)
        {
            Console.WriteLine(@"Container content:");
            Console.WriteLine(@"------------------");
            // Print the root node first, if specified
            if (rootNode != null)
                Console.WriteLine(rootNode.PrintHierarchy());

            // Print other nodes next
            // TODO: FIXME
            //foreach (var node in container.Guids.Select(container.GetNode).Where(x => x != rootNode))
            //{
            //    Console.WriteLine(node.PrintHierarchy());
            //}
            Console.WriteLine(@"------------------");
        }
Example #4
0
        public void TestSimpleContent()
        {
            var obj = new SimpleClass(1, "test");

            Assert.That(obj.FirstValue, Is.EqualTo(1));
            Assert.That(obj.SecondValue, Is.EqualTo("test"));

            var        container = new NodeContainer();
            IGraphNode model     = container.GetOrCreateNode(obj);

            Console.WriteLine(model.PrintHierarchy());
            model.GetChild("FirstValue").Content.Update(2);
            model.GetChild("SecondValue").Content.Update("new value");

            Assert.That(obj.FirstValue, Is.EqualTo(2));
            Assert.That(obj.SecondValue, Is.EqualTo("new value"));
        }
Example #5
0
File: Helper.cs Project: zetz/xenko
        public static void PrintModelContainerContent(NodeContainer container, IGraphNode rootNode = null)
        {
            Console.WriteLine(@"Container content:");
            Console.WriteLine(@"------------------");
            // Print the root node first, if specified
            if (rootNode != null)
            {
                Console.WriteLine(rootNode.PrintHierarchy());
            }

            // Print other nodes next
            // TODO: FIXME
            //foreach (var node in container.Guids.Select(container.GetNode).Where(x => x != rootNode))
            //{
            //    Console.WriteLine(node.PrintHierarchy());
            //}
            Console.WriteLine(@"------------------");
        }