public void As_RecursiveDescentAppliedToPropertyToArrayIndex_ReturnsNull()
        {
            JsonPathElement element = new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(JsonPathElementType.Property));

            var actual = element.As <JsonPathArrayIndexElement>();

            actual.Should().BeNull();
        }
        public void GetUnderlyingElement_Property_ReturnsProperty()
        {
            var element = ElementCreator.CreateAny(JsonPathElementType.Property);

            var actual = element.GetUnderlyingElement();

            actual.Should().Be(element);
        }
        public void As_PropertyToArrayIndex_ReturnsNull()
        {
            var element = ElementCreator.CreateAny(JsonPathElementType.Property);

            var actual = element.As <JsonPathArrayIndexElement>();

            actual.Should().BeNull();
        }
        public void As_PropertyToProperty_Casts()
        {
            var element = ElementCreator.CreateAny(JsonPathElementType.Property);

            var actual = element.As <JsonPathPropertyElement>();

            actual.Should().Be(element);
        }
        public void CastTo_RecursiveDescentAppliedToPropertyToArrayIndex_Throws()
        {
            JsonPathElement element = new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(JsonPathElementType.Property));

            Action action = () => element.CastTo <JsonPathArrayIndexElement>();

            action.Should().Throw <InvalidCastException>();
        }
        public void CastTo_PropertyToArrayIndex_Throws()
        {
            var element = ElementCreator.CreateAny(JsonPathElementType.Property);

            Action action = () => element.CastTo <JsonPathArrayIndexElement>();

            action.Should().Throw <InvalidCastException>();
        }
        public void As_RecursiveDescentAppliedToPropertyToProperty_Casts()
        {
            var             property = ElementCreator.CreateAny(JsonPathElementType.Property);
            JsonPathElement element  = new JsonPathRecursiveDescentElement(property);

            var actual = element.As <JsonPathPropertyElement>();

            actual.Should().Be(property);
        }
        public void Matches_Any_ReturnsFalse(JsonPathElementType type)
        {
            var element = new JsonPathArrayIndexElement(7);
            var other   = ElementCreator.CreateAny(type);

            bool?actual = element.Matches(other);

            actual.Should().BeFalse();
        }
        public void Matches_Any(JsonPathElementType type, bool?expected)
        {
            var element = new JsonPathArraySliceElement(null, null);
            var other   = ElementCreator.CreateAny(type);

            bool?actual = element.Matches(other);

            actual.Should().Be(expected);
        }
        public void Matches_Any_ReturnsFalse(JsonPathElementType type)
        {
            var element = new JsonPathPropertyListElement(new[] { "name0", "name1" });
            var other   = ElementCreator.CreateAny(type);

            bool?actual = element.Matches(other);

            actual.Should().BeFalse();
        }
        public void Matches_Any(JsonPathElementType type, bool?expected)
        {
            var element = new JsonPathFilterExpressionElement("@.name");
            var other   = ElementCreator.CreateAny(type);

            bool?actual = element.Matches(other);

            actual.Should().Be(expected);
        }
        public void Matches_Any(JsonPathElementType type, bool?expected)
        {
            var element = new JsonPathRecursiveDescentElement(new JsonPathArrayIndexElement(0));
            var other   = ElementCreator.CreateAny(type);

            bool?actual = element.Matches(other);

            actual.Should().Be(expected);
        }
예제 #13
0
        public void Matches(JsonPathElementType type, bool?expected)
        {
            var element = new JsonPathAnyPropertyElement();
            var other   = ElementCreator.CreateAny(type);

            bool?actual = element.Matches(other);

            actual.Should().Be(expected);
        }
        public void GetUnderlyingElement_RecursiveDescentAppliedToProperty_ReturnsProperty()
        {
            var             property = ElementCreator.CreateAny(JsonPathElementType.Property);
            JsonPathElement element  = new JsonPathRecursiveDescentElement(property);

            var actual = element.GetUnderlyingElement();

            actual.Should().Be(property);
        }
        public void IsOfTypeInRange(bool expected, JsonPathElementType elementType, bool isRecursiveDescent, JsonPathElementType firstType, JsonPathElementType lastType)
        {
            var element = isRecursiveDescent
                ? new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(elementType))
                : ElementCreator.CreateAny(elementType);

            bool actual = element.IsOfTypeInRange(firstType, lastType);

            actual.Should().Be(expected);
        }
        public void IsOfType_SingleType(JsonPathElementType elementType, bool isRecursiveDescent, JsonPathElementType typeArg, bool expected)
        {
            var element = isRecursiveDescent
                ? new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(elementType))
                : ElementCreator.CreateAny(elementType);

            bool actual = element.IsOfType(typeArg);

            actual.Should().Be(expected);
        }
        public void IsOfType_MultipleTypes(bool expected, JsonPathElementType elementType, bool isRecursiveDescent, params JsonPathElementType[] typeArgs)
        {
            var element = isRecursiveDescent
                ? new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(elementType))
                : ElementCreator.CreateAny(elementType);

            bool actual = element.IsOfType(typeArgs);

            actual.Should().Be(expected);
        }