Exemplo n.º 1
0
        TestObject1 CreateObject1(List <object> objects)
        {
            TestObject1 obj1 = new TestObject1();

            objects.Add(obj1);
            obj1.Name         = "test";
            obj1.Idx          = 2;
            obj1.Storable     = CreateObject2(objects);
            obj1.StorableList = new List <TestObject2> ();
            for (int i = 0; i < 5; i++)
            {
                obj1.StorableList.Add(CreateObject2(objects));
            }
            obj1.StorableDict       = new Dictionary <string, TestObject2> ();
            obj1.StorableDict ["1"] = CreateObject2(objects);
            obj1.StorableDict ["2"] = CreateObject2(objects);
            obj1.NotStorableList    = new List <TestObject3> ();
            for (int i = 0; i < 5; i++)
            {
                obj1.NotStorableList.Add(CreateObject3(objects));
            }
            return(obj1);
        }
Exemplo n.º 2
0
        public void TestParsedAndResetstorables()
        {
            StorableNode        parent;
            List <IStorable>    storables = null, changed = null;
            ObjectChangedParser parser = new ObjectChangedParser();
            TestObject1         obj1   = new TestObject1();

            obj1.Storable           = new TestObject2();
            obj1.Ignored            = new TestObject2();
            obj1.IsChanged          = true;
            obj1.Storable.IsChanged = true;
            Assert.IsTrue(parser.ParseInternal(out parent, obj1, Serializer.JsonSettings));
            Assert.IsTrue(parent.ParseTree(ref storables, ref changed));
            Assert.AreEqual(2, parser.parsedCount);
            Assert.AreEqual(2, changed.Count);
            Assert.AreEqual(2, storables.Count);
            storables = null;
            changed   = null;
            Assert.IsTrue(parser.ParseInternal(out parent, obj1, Serializer.JsonSettings));
            Assert.IsTrue(parent.ParseTree(ref storables, ref changed));
            Assert.AreEqual(2, parser.parsedCount);
            Assert.AreEqual(0, changed.Count);
            Assert.AreEqual(2, storables.Count);
        }