fluentassertions
fluentassertions copied to clipboard
JTokenAssertions.BeEquivalentTo should format the JSON document in a more readable fashion
Build 2 JObjects that are not DeepEquals. Call BeEquivalentTo on them and inspect the output message.
JObject result = ...;
JObject baseline = ...;
baseline
.Should()
.BeEquivalentTo(result);
Expected results
The message should be readable and easy to parse by a human. ex.
Expected: {
"runtimeTarget": {
"name": ".NETCoreApp,Version=v1.0",
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v1.0": {
"dotnet.new/1.0.0": {
"runtime": {
"dotnet.new.dll": {}
}
}
}
},
"libraries": {
"DOTNET.new/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Result: {
"runtimeTarget": {
"name": ".NETCoreApp,Version=v1.0",
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v1.0": {
"dotnet.new/1.0.0": {
"runtime": {
"dotnet.new.dll": {}
}
}
}
},
"libraries": {
"dotnet.new/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Actual results
The output is pretty hard to decipher
Expected JSON document { "runtimeTarget": { "name": ".NETCoreApp,Version=v1.0", "signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709" }, "compilationOptions": {}, "targets": { ".NETCoreApp,Version=v1.0": { "dotnet.new/1.0.0": { "runtime": { "dotnet.new.dll": {} } } } }, "libraries": { "DOTNET.new/1.0.0": { "type": "project", "serviceable": false, "sha512": "" } }} to be equivalent to { "runtimeTarget": { "name": ".NETCoreApp,Version=v1.0", "signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709" }, "compilationOptions": {}, "targets": { ".NETCoreApp,Version=v1.0": { "dotnet.new/1.0.0": { "runtime": { "dotnet.new.dll": {} } } } }, "libraries": { "dotnet.new/1.0.0": { "type": "project", "serviceable": false, "sha512": "" } }}, but differs at "libraries": { "dotnet.new/1.0.0": { "type": "project", "serviceable": false, "sha512": "" }, "@@ Removed": [ "DOTNET.new/1.0.0" ]}.
I think putting some newlines in here would make it much easier to read.