Skip to content

Commit

Permalink
Removing _comparisonPasses from the HttpBodyComparer as JsonConvert.S…
Browse files Browse the repository at this point in the history
…erializeObject will throw if there is potential for an infinite loop
  • Loading branch information
neilcampbell committed Sep 4, 2014
1 parent 5c00091 commit 9bb3e6d
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions PactNet/Mocks/MockHttpService/Comparers/HttpBodyComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class HttpBodyComparer : IHttpBodyComparer
{
private readonly string _messagePrefix;
private readonly IReporter _reporter;
private int _comparisonPasses;

public HttpBodyComparer(string messagePrefix, IReporter reporter)
{
Expand All @@ -20,8 +19,6 @@ public HttpBodyComparer(string messagePrefix, IReporter reporter)
//TODO: Remove boolean and add "matching" functionality
public void Validate(dynamic expected, dynamic actual, bool useStrict = false)
{
_comparisonPasses = 0;

if (expected == null)
{
return;
Expand All @@ -33,6 +30,8 @@ public void Validate(dynamic expected, dynamic actual, bool useStrict = false)
return;
}


//TODO: Maybe look at changing these to JToken.FromObject(...)
string expectedJson = JsonConvert.SerializeObject(expected);
string actualJson = JsonConvert.SerializeObject(actual);
var expectedToken = JsonConvert.DeserializeObject<JToken>(expectedJson);
Expand All @@ -53,13 +52,6 @@ public void Validate(dynamic expected, dynamic actual, bool useStrict = false)

private bool AssertPropertyValuesMatch(JToken httpBody1, JToken httpBody2)
{
_comparisonPasses++;
if (_comparisonPasses > 200)
{
_reporter.ReportError("Too many passes required to compare objects.");
return false;
}

switch (httpBody1.Type)
{
case JTokenType.Array:
Expand Down

0 comments on commit 9bb3e6d

Please sign in to comment.