public void ReplaceLastWith_RootElementInAbsolutePath_Throws()
        {
            var path = new AbsoluteJsonPathExpression(new JsonPathElement[] { new JsonPathRootElement() });

            Action action = () => path.ReplaceLastWith(new JsonPathPropertyElement("a"));

            action.Should().Throw <ArgumentException>();
        }
        public void Constructor_AbsolutePath_Succeeds()
        {
            var elements = new JsonPathElement[] { new JsonPathRootElement(), new JsonPathPropertyElement("a") };

            var actual = new AbsoluteJsonPathExpression(elements);

            actual.Elements.Should().BeEquivalentTo(elements);
        }
        public void ToAbsolute(string path, string expected)
        {
            var pathExpr     = new JsonPathExpression(path);
            var expectedExpr = new AbsoluteJsonPathExpression(expected);

            var actual = pathExpr.ToAbsolute();

            actual.Should().BeEquivalentTo(expectedExpr);
        }
        public void GetParentWith_AbsolutePath(string path, string other, string expected)
        {
            var pathExpr     = new AbsoluteJsonPathExpression(path);
            var otherExpr    = new AbsoluteJsonPathExpression(other);
            var expectedExpr = expected != null ? new JsonPathExpression(expected) : null;

            var actual = pathExpr.GetParentWith(otherExpr);

            actual.Should().BeEquivalentTo(expectedExpr);
        }
        public void ToAbsolute_AbsoluteJsonPathExpression_ReturnsPassedExpression()
        {
            var path = new AbsoluteJsonPathExpression(new JsonPathElement[]
            {
                new JsonPathRootElement(), new JsonPathPropertyElement("a")
            });

            var actual = path.ToAbsolute();

            actual.Should().Be(path);
        }
        public void Create_ReturnsObjectOfTheSameType()
        {
            var path = new AbsoluteJsonPathExpression(new JsonPathElement[]
            {
                new JsonPathRootElement()
            });
            var elements = new JsonPathElement[]
            {
                new JsonPathRootElement(),
                new JsonPathPropertyElement("a"),
                new JsonPathArrayIndexElement(42)
            };

            var actual = path.Create(elements);

            actual.Elements.Should().BeEquivalentTo(elements);
            actual.GetType().Should().Be <AbsoluteJsonPathExpression>();
        }