Exemplo n.º 1
0
        public void DeserializeUntypedTest <K, V>(IDictionary <K, V> expected, string json)
        {
            var serializer = new VJson.JsonSerializer(typeof(object));
            var actual     = serializer.Deserialize(json);

            Assert.That(actual, Is.EquivalentTo(expected));
        }
Exemplo n.º 2
0
        public void DeserializeImplicitConstructableTest()
        {
            var serializer = new VJson.JsonSerializer(typeof(Hoge));
            var actual     = (Hoge)serializer.Deserialize(@"true");

            Assert.That(actual.B, Is.EqualTo(true));
        }
Exemplo n.º 3
0
        public void DeserializeTest <E>(IEnumerable <E> expected, string json)
        {
            var serializer = new VJson.JsonSerializer(expected != null ? expected.GetType() : typeof(object));
            var actual     = serializer.Deserialize(json);

            Assert.That(actual, Is.EquivalentTo(expected));
        }
Exemplo n.º 4
0
        public void DeserializeFromStringTest(object obj, string expected)
        {
            var serializer = new VJson.JsonSerializer(obj != null ? obj.GetType() : typeof(object));
            var actual     = serializer.Deserialize(expected);

            Assert.AreEqual(obj, actual);
        }
Exemplo n.º 5
0
        public void DeserializeHasHintFieldsBoolTest()
        {
            var serializer = new VJson.JsonSerializer(typeof(CustomObject));
            var actual     = (CustomObject)serializer.Deserialize(@"{""Obj"": true}");

            Assert.AreEqual(typeof(bool), actual.Obj.GetType());
            Assert.AreEqual(true, actual.Obj);
        }
Exemplo n.º 6
0
        public void DeserializeHasHintFieldsClassTest()
        {
            var serializer = new VJson.JsonSerializer(typeof(CustomObject));
            var actual     = (CustomObject)serializer.Deserialize(@"{""Obj"": {""X"":10}}");

            Assert.AreEqual(typeof(SomeObject), actual.Obj.GetType());
            Assert.AreEqual(new SomeObject
            {
                X = 10,
            }, actual.Obj);
        }
Exemplo n.º 7
0
        public void DeserializeHasHintFieldsArrayOrSingletonSgtTest()
        {
            var serializer = new VJson.JsonSerializer(typeof(CustomObjectHasArray));
            var actual     = (CustomObjectHasArray)serializer.Deserialize(@"{""Obj"": {""X"":10}}");

            Assert.AreEqual(typeof(SomeObject), actual.Obj.GetType());
            Assert.That(actual.Obj,
                        Is.EqualTo(new SomeObject
            {
                X = 10,
            })
                        );
        }