public void TestToSimpleObject()
        {
            var dictionary = new Dictionary <string, object>
            {
                ["StringValue"] = "Test Value"
            };

            var mutableDocument = new MutableDocument("test_id", dictionary);

            var simpleObject = mutableDocument.ToObject <TestObjects.SimpleObject>();

            object obj = mutableDocument.ToObject(typeof(TestObjects.SimpleObject));
        }
        public void TestToSimpleObjectWithSimpleArray()
        {
            var dictionary = new Dictionary <string, object>
            {
                ["StringValue"] = "Test Value",
                ["ArrayValue"]  = new string[] { "Value1", "Value2" }
            };

            var mutableDocument = new MutableDocument("test_id", dictionary);

            var generic = mutableDocument.ToObject <TestObjects.SimpleObject>();

            object nonGeneric = mutableDocument.ToObject(typeof(TestObjects.SimpleObject));
        }
Ejemplo n.º 3
0
        public void TestToSimpleEnum()
        {
            var dictionary = new Dictionary <string, object>
            {
                ["SimpleEnum"] = "EnumValue_2",
            };

            var mutableDocument = new MutableDocument("test_id", dictionary);

            var simpleObject = mutableDocument.ToObject <SimpleObjectWithEnum>();

            Assert.Equal(SimpleEnum.Enum_2, simpleObject.SimpleEnum);
        }
        public void TestFallbackType()
        {
            SimpleObject obj = new SimpleObject()
            {
                StringValue = "Hey"
            };

            MutableDocument doc = obj.ToMutableDocument();

            doc.SetString("$type", "not a type");

            object newObject = doc.ToObject(typeof(SimpleObject));
        }
        public void TestToSimpleObjectWithSimpleList()
        {
            var dictionary = new Dictionary <string, object>
            {
                ["StringValue"] = "Test Value",
                ["ListValue"]   = new List <string> {
                    "Value1", "Value2"
                }
            };

            var mutableDocument = new MutableDocument("test_id", dictionary);

            var simpleObject = mutableDocument.ToObject <TestObjects.SimpleObject>();
        }