public void Parse(string pointerString, int parentSteps, string[] segments) { var pointer = RelativeJsonPointer.Parse(pointerString); pointer.ParentSteps.Should().Be((uint)parentSteps); pointer.Pointer.Segments.Length.Should().Be(segments.Length); pointer.Pointer.Segments.Select(s => s.Value).Should().BeEquivalentTo(segments); }
public void EvaluateSuccess(string pointerString, string expectedString) { using var json = JsonDocument.Parse("{\"foo\":[\"bar\",\"baz\"],\"highly\":{\"nested\":{\"objects\":true}}}"); var startElement = json.RootElement.GetProperty("foo")[1]; var pointer = RelativeJsonPointer.Parse(pointerString); using var expected = JsonDocument.Parse(expectedString); #pragma warning disable 618 var actual = pointer.Evaluate(startElement); #pragma warning restore 618 Assert.True(actual.IsEquivalentTo(expected.RootElement)); }
public void ParseFailure(string pointerString) { Assert.Throws <PointerParseException>(() => RelativeJsonPointer.Parse(pointerString)); }