コード例 #1
0
        public void Visit_WithObjects_VisitsAllNodes()
        {
            JToken token = JToken.Parse("{ string: 'String', obj: { child_string: 'Child String' } }");

            NullTestVisitor visitor = new NullTestVisitor();

            visitor.DoAccept(token, new NullJsonVisitorContext());

            Assert.That(visitor,
                        Has.Exactly(1).EqualTo("string = String")
                        & Has.Exactly(1).EqualTo("obj.child_string = Child String"));
        }
コード例 #2
0
        public void Visit_String_Some()
        {
            JToken token = JToken.Parse("{ name: 'String', other: 42 }");

            NullTestVisitor visitor = new NullTestVisitor();

            visitor.DoAccept(token, new NullJsonVisitorContext());

            Assert.That(visitor,
                        Has.Count.EqualTo(2)
                        & Has.Exactly(1).EqualTo("name = String")
                        & Has.Exactly(1).EqualTo("other = 42"));
        }
コード例 #3
0
        public void Visit_WithSimpleArray_VisitsAllNodes()
        {
            JToken token = JToken.Parse("{ string: 'String', arr: ['Zero', 'One', 'Two'] }");

            NullTestVisitor visitor = new NullTestVisitor();

            visitor.DoAccept(token, new NullJsonVisitorContext());

            Assert.That(visitor,
                        Has.Exactly(1).EqualTo("string = String")
                        & Has.Exactly(1).EqualTo("arr[0] = Zero")
                        & Has.Exactly(1).EqualTo("arr[1] = One")
                        & Has.Exactly(1).EqualTo("arr[2] = Two")
                        );
        }