Esempio n. 1
0
        public void ParseTermInChild()
        {
            // Arrange
            var doc = new JObject(new JProperty("foo", "bar"),
                                    new JProperty("child",
                                            new JObject(new JProperty("Ick", "much"), new JProperty("Ock", "wow"))));
            var localObject = new LocalType();

            // Act
            var root = new VocabTerm<LocalType>();
            var child = new VocabTerm<LocalChildType>("child");

            child.MapProperty<string>("Ick", (s, o) => s.Ick = o);
            child.MapProperty<string>("Ock", (s, o) => s.Ock = o);

            root.MapObject<LocalChildType>(child, (s) =>
            {
                var subject = s;
                subject.Child = new LocalChildType();
                return subject.Child;
            });

            JsonStreamingParser.ParseStream(doc.ToMemoryStream(), localObject, root);

            // Assert
            Assert.Equal("much", localObject.Child.Ick);
            Assert.Equal("wow", localObject.Child.Ock);
        }
Esempio n. 2
0
        public void ParseTerm()
        {

            // Arrange
            var doc = new JObject(new JProperty("foo", "bar"), new JProperty("baz", 22));
            var localObject = new LocalType();

            // Act
            var rootMap = new VocabTerm<LocalType>();
            rootMap.MapProperty<string>("foo", (s, o) => s.Foo = o);
            rootMap.MapProperty<int>("baz", (s, o) => s.Baz = o);

            JsonStreamingParser.ParseStream(doc.ToMemoryStream(), localObject, rootMap);

            // Assert
            Assert.Equal("bar", localObject.Foo);
            Assert.Equal(22, localObject.Baz);
        }