Skip to content

Commit

Permalink
Fixed memory leak bug caused by query list keyvaluepair variable para…
Browse files Browse the repository at this point in the history
…ms (#5718)
  • Loading branch information
declan-bourke committed Jan 30, 2023
1 parent 8663fb7 commit 3dc6a8c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Expand Up @@ -171,6 +171,14 @@ private static bool ObjEqual(object? first, object? second)
{
return DictionaryEqualInternal(firstReadDict, secondReadDict);
}

if (first is IEnumerable<KeyValuePair<string, object?>> firstKvp &&
second is IEnumerable<KeyValuePair<string, object?>> secondKvp)
{
return DictionaryEqualInternal(
firstKvp.ToDictionary(t => t.Key, t => t.Value),
secondKvp.ToDictionary(t => t.Key, t => t.Value));
}

if (first is not string &&
second is not string &&
Expand Down
Expand Up @@ -551,6 +551,48 @@ public void Equals_With_Variables_JSON()
Assert.True(a.Equals(b));
}

[Fact]
public void Equals_With_Variables_KeyValuePair()
{
// arrange
var document = new Mock<IDocument>();
var a = new OperationRequest(
null,
"abc",
document.Object,
new Dictionary<string, object?>
{
{ "a", new List<KeyValuePair<string, object?>>
{
new KeyValuePair<string, object?>("b", new List<KeyValuePair<string, object?>>
{
new KeyValuePair<string, object?>("id", "123456")
})
}
}
});

var b = new OperationRequest(
null,
"abc",
document.Object,
new Dictionary<string, object?>
{
{ "a", new List<KeyValuePair<string, object?>>
{
new KeyValuePair<string, object?>("b", new List<KeyValuePair<string, object?>>
{
new KeyValuePair<string, object?>("id", "123456")
})
}
}
});

// act
// assert
Assert.True(a.Equals(b));
}

[Fact]
public void Equals_No_Variables()
{
Expand Down

0 comments on commit 3dc6a8c

Please sign in to comment.