Example #1
0
        internal static List <string> Match(dynamic expectedBody, dynamic actualBody, MatchingRuleCollection matchingRules)
        {
            var differences = new List <string>();

            if (expectedBody == null)
            {
                return(differences);
            }

            if (actualBody == null)
            {
                differences.Add("Expected body or contents to be present, but was not.");
                return(differences);
            }

            JToken expectedRootToken = JTokenParser.Parse(expectedBody);
            JToken actualRootToken   = JTokenParser.Parse(actualBody);

            foreach (var token in expectedRootToken.ThisTokenAndAllItsDescendants())
            {
                differences.AddRange(ProcessToken(token, matchingRules, actualRootToken));
            }

            differences.AddRange(VerifyAdditionalActualTokensAgainstMatchingRules(expectedRootToken, actualRootToken, matchingRules));

            return(differences);
        }
Example #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jToken = (JToken)serializer.Deserialize(reader);
            var parser = new JTokenParser(jToken);

            return(parser.Parse());
        }