Skip to content

Commit 44bf1be

Browse files
committed
Add AssertJsonResponse overload that accepts existing JSON string
1 parent 32d4cb5 commit 44bf1be

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/Dibix.Testing/TestBase.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,15 @@ protected void AssertJsonResponse<T>(T response, Action<JsonSerializerSettings>
134134
};
135135
configureSerializer?.Invoke(settings);
136136

137+
string responseJson = JsonConvert.SerializeObject(response, settings);
138+
AssertJsonResponse(responseJson, outputName, expectedText);
139+
}
140+
protected void AssertJsonResponse(string responseJson, string outputName = null, string expectedText = null)
141+
{
137142
const string extension = "json";
138143
string outputNameResolved = outputName ?? TestContext.TestName;
139144
string expectedTextResolved = expectedText ?? GetEmbeddedResourceContent($"{outputNameResolved}.{extension}");
140-
string actualText = JsonConvert.SerializeObject(response, settings);
145+
string actualText = responseJson;
141146
JToken actualTextDom = JToken.Parse(actualText);
142147

143148
// Replace JSON path placeholders in the expected text with values from the actual text

0 commit comments

Comments
 (0)