Esempio n. 1
0
        private static void AssertCollectionIsNull(CollectionHolder <Item> holder, string collectionFieldName)
        {
            FieldInfo field      = holder.GetType().GetField(collectionFieldName, BindingFlags.Instance | BindingFlags.NonPublic);
            Object    fieldValue = field.GetValue(holder);

            Assert.IsNull(fieldValue);
        }
Esempio n. 2
0
    public static void RunCollectionTest()
    {
        var obj = new CollectionHolder();

        obj.dict["foo1"] = "bar1";
        obj.dict["foo2"] = "bar2";
        obj.list.Add(1);
        obj.list.Add(2);
        obj.arr    = new[] { true, false };
        obj.nested = new CollectionHolder();
        obj.nested.dict["nested1"] = "ack1";
        obj.nested.arr             = new[] { true };

        Dictionary <ObjectDataPath[], object> model         = new SavedObject(obj).state;
        Dictionary <string, object>           readableModel = SavedObjectDelta.ReadableModel(model);

        // TODO: If list is null, we will include it, but if it is empty we will
        //       not

        Assert.AreEqual(11, readableModel.Count);
        Assert.AreEqual(obj.GetType(), readableModel["GetType()"]);
        Assert.AreEqual("bar1", readableModel["dict.foo1"]);
        Assert.AreEqual("bar2", readableModel["dict.foo2"]);
        Assert.AreEqual(1, readableModel["list.0"]);
        Assert.AreEqual(2, readableModel["list.1"]);
        Assert.AreEqual(true, readableModel["arr.0"]);
        Assert.AreEqual(false, readableModel["arr.1"]);
        Assert.AreEqual(obj.nested.GetType(), readableModel["nested:GetType()"]);
        Assert.AreEqual("ack1", readableModel["nested:dict.nested1"]);
        Assert.AreEqual(true, readableModel["nested:arr.0"]);
        Assert.AreEqual(null, readableModel["nested:nested"]);
    }
Esempio n. 3
0
    public static void RunCollectionTest()
    {
        var obj = new CollectionHolder();
        obj.dict["foo1"] = "bar1";
        obj.dict["foo2"] = "bar2";
        obj.list.Add(1);
        obj.list.Add(2);
        obj.arr = new[] { true, false };
        obj.nested = new CollectionHolder();
        obj.nested.dict["nested1"] = "ack1";
        obj.nested.arr = new[] { true };

        Dictionary<ObjectDataPath[], object> model = new SavedObject(obj).state;
        Dictionary<string, object> readableModel = SavedObjectDelta.ReadableModel(model);

        // TODO: If list is null, we will include it, but if it is empty we will
        //       not

        Assert.AreEqual(11, readableModel.Count);
        Assert.AreEqual(obj.GetType(), readableModel["GetType()"]);
        Assert.AreEqual("bar1", readableModel["dict.foo1"]);
        Assert.AreEqual("bar2", readableModel["dict.foo2"]);
        Assert.AreEqual(1, readableModel["list.0"]);
        Assert.AreEqual(2, readableModel["list.1"]);
        Assert.AreEqual(true, readableModel["arr.0"]);
        Assert.AreEqual(false, readableModel["arr.1"]);
        Assert.AreEqual(obj.nested.GetType(), readableModel["nested:GetType()"]);
        Assert.AreEqual("ack1", readableModel["nested:dict.nested1"]);
        Assert.AreEqual(true, readableModel["nested:arr.0"]);
        Assert.AreEqual(null, readableModel["nested:nested"]);
    }
Esempio n. 4
0
		private static void AssertCollectionIsNull(CollectionHolder<Item> holder, string collectionFieldName)
		{
			FieldInfo field = holder.GetType().GetField(collectionFieldName, BindingFlags.Instance | BindingFlags.NonPublic);
			Object fieldValue = field.GetValue(holder);
			Assert.IsNull(fieldValue);
		}