public void ShouldNotFindForChildToken()
        {
            var token      = JToken.FromObject(new { name = "test" });
            var collection = new MatchingRuleCollection {
                Body = new Dictionary <string, MatcherList> {
                    { "$.name", _typeMatcherList }
                }
            };

            var isFound = collection.TryGetApplicableMatcherListForToken(token.Root, out var applicableMatcherList);

            Assert.IsFalse(isFound);
        }
        public void ShouldNotFindWhenEqualityMatcherListIsApplicable()
        {
            var token      = JToken.FromObject(new { name = "test" });
            var collection = new MatchingRuleCollection {
                Body = new Dictionary <string, MatcherList> {
                    { "$", _typeMatcherList }, { "$.name", _equalityMatcherList }
                }
            };

            var isFound = collection.TryGetApplicableMatcherListForToken(token.Children().First(), out var applicableMatcherList);

            Assert.IsFalse(isFound);
        }
        public void ShouldFindForParentToken()
        {
            var token      = JToken.FromObject(new { name = "test" });
            var collection = new MatchingRuleCollection {
                Body = new Dictionary <string, MatcherList> {
                    { "$", _typeMatcherList }
                }
            };

            var isFound = collection.TryGetApplicableMatcherListForToken(token.Children().First(), out var applicableMatcherList);

            Assert.IsTrue(isFound);
            Assert.AreEqual(_typeMatcherList, applicableMatcherList);
        }
        public void ShouldIgnoreStarWhenMoreSpecificOptionExists()
        {
            var token      = JToken.FromObject(new { name = "test" });
            var collection = new MatchingRuleCollection {
                Body = new Dictionary <string, MatcherList> {
                    { "$.*", _typeMatcherList }, { "$.name", _integerMatcherList }
                }
            };

            var isFound = collection.TryGetApplicableMatcherListForToken(token.Children().First(), out var applicableMatcherList);

            Assert.IsTrue(isFound);
            Assert.AreEqual(_integerMatcherList, applicableMatcherList);
        }
        public void ShouldFindWithStarAnywhereInPath()
        {
            var token      = JToken.FromObject(new { thing = new { name = "test" } });
            var collection = new MatchingRuleCollection {
                Body = new Dictionary <string, MatcherList> {
                    { "$.*.name", _typeMatcherList }
                }
            };

            var isFound = collection.TryGetApplicableMatcherListForToken(token.SelectToken("thing.name"), out var applicableMatcherList);

            Assert.IsTrue(isFound);
            Assert.AreEqual(_typeMatcherList, applicableMatcherList);
        }