Exemplo n.º 1
0
        public void SetToCollectionWithOneEmptyObject_ExpectedJsonPatternReturned()
        {
            string document = JsonBuilder
                              .CreateObject()
                              .With("first", SetTo.AnArrayContaining(item => { }))
                              .And("second", SetTo.Value("test2"));

            Assert.Equal($@"{{""first"":[{{}}],""second"":""test2""}}", document);
        }
Exemplo n.º 2
0
        public void SetToCollectionWithTwoComplexObjects_ExpectedJsonPatternReturned()
        {
            string document = JsonBuilder
                              .CreateObject()
                              .With("first", SetTo.AnArrayContaining(
                                        item => { item.With("first", SetTo.Value("hasValue")); },
                                        item => { item.With("second", SetTo.Value("alsoHasAValue")); }))
                              .And("second", SetTo.Value("test2"));

            Assert.Equal(
                $@"{{""first"":[{{""first"":""hasValue""}},{{""second"":""alsoHasAValue""}}],""second"":""test2""}}",
                document);
        }
Exemplo n.º 3
0
        public void SetToCollectionThenUpdatedByRemoving_ExpectedJsonPatternReturned()
        {
            string document = JsonBuilder
                              .CreateObject()
                              .With("first", SetTo.AnArrayContaining(
                                        item => item.With("aProperty", SetTo.Value("AValue")),
                                        item => { }))
                              .And("second", SetTo.Value("test2"))
                              .With("first", Updated.ByRemovingAtIndex(0))
                              .With("first", Updated.AtIndex(0,
                                                             item => item.With("second", SetTo.Value("NewValue"))));

            Assert.Equal($@"{{""first"":[{{""second"":""NewValue""}}],""second"":""test2""}}", document);
        }
Exemplo n.º 4
0
        public void SetToCollectionThenInsertAtIndex0_ExpectedJsonPatternReturned()
        {
            string document = JsonBuilder
                              .CreateObject()
                              .With("first", SetTo.AnArrayContaining(
                                        item => item.With("number", SetTo.Value("one")),
                                        item => { }))
                              .And("second", SetTo.Value("test2"))
                              .With("first", Updated.WithArrayItemsInsertedAtIndex(0,
                                                                                   item => item.With("number", SetTo.Value("zero"))))
                              .With("first", Updated.AtIndex(2,
                                                             item => item.With("aNother", SetTo.Value("NewValue"))));

            Assert.Equal($@"{{""first"":[{{""number"":""zero""}},{{""number"":""one""}},{{""aNother"":""NewValue""}}],""second"":""test2""}}", document);
        }
 internal ItemObject WithTags(params Action <TagObject>[] initialisers)
 {
     return(With("tags", SetTo.AnArrayContaining(initialisers)));
 }
 internal ComplexObject WithItems(params Action <ItemObject>[] initialisers)
 {
     return(With("items", SetTo.AnArrayContaining(initialisers)));
 }