예제 #1
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);
        }
예제 #2
0
        public void SetToCollectionThenUpdated_ExpectedJsonPatternReturned()
        {
            string document = JsonBuilder
                              .CreateObject()
                              .With("first", SetTo.AnArrayContaining(item => { }, item => { }))
                              .And("second", SetTo.Value("test2"))
                              .With("first", Updated.AtIndex(0,
                                                             item => item.With("first", SetTo.Value("hasValue"))))
                              .With("first", Updated.AtIndex(1,
                                                             item => item.With("second", SetTo.Value("alsoHasAValue"))));

            Assert.Equal(
                $@"{{""first"":[{{""first"":""hasValue""}},{{""second"":""alsoHasAValue""}}],""second"":""test2""}}",
                document);
        }
예제 #3
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 UpdateExistingTagAtIndex(int index, Action <TagObject> update)
 {
     return(With("tags", Updated.AtIndex(index, update)));
 }
 internal ComplexObject UpdateExistingTagAtIndex(int index, Action <ItemObject> update)
 {
     return(With("items", Updated.AtIndex(index, update)));
 }