public bool IsMatch(Dictionary <string, MatchingRule> ruleset, Dictionary <string, object> expected, Dictionary <string, object> actual, PactLogBuilder log) { var finder = new RuleFinder(); var match = true; foreach (var expectedKey in expected.Keys) { if (!actual.ContainsKey(expectedKey)) { match = false; log.NotFound(expectedKey); } else { var expectedValue = expected[expectedKey]; var actualValue = actual[expectedKey]; var rule = finder.FindRule(expectedKey, ruleset); if (!IsMatch(rule, expectedValue, actualValue)) { match = false; log.Unmatched(expectedValue, actualValue, rule); } } } return(match); }
public bool IsMatch(Dictionary <string, MatchingRule> ruleset, Dictionary <string, List <string> > expected, Dictionary <string, List <string> > actual, PactLogBuilder log) { bool match = true; var ruleFinder = new RuleFinder(); foreach (var keyValuePair in expected) { var corresponding = Find(actual, keyValuePair.Key); if (corresponding.Key == null) { log.NotFound(corresponding.Key); match = false; } else { var path = $"$.headers.{keyValuePair.Key}"; var expectedMatchingRule = ruleFinder.FindRule(path, ruleset); foreach (var expectedValue in keyValuePair.Value) { if (!ContainsMatch(expectedMatchingRule, expectedValue, corresponding.Value)) { match = false; log.NotFound(path); } } } } return(match); }