Skip to content

ShouldBeEquivalentTo ignores differences in deserialized objects #1785

Answered by dennisdoomen
ccarmannt asked this question in Q&A
Discussion options

You must be logged in to vote

That's because you're comparing two instances of type object, which doesn't define any compile-time properties. But even if you would use the options to force FA to respect the runtime types, the behavior is difficult to predict. JSonConvert returns a complicated graph of JContainer instances. Instead, I recommend using FluentAssertion.Json. It also has a BeEquivalentTo method that was specifically designed to work with Json objects. Just make sure you use using FluentAssertions.Json.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ccarmannt
Comment options

Answer selected by ccarmannt
Comment options

You must be logged in to vote
1 reply
@ccarmannt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1784 on January 22, 2022 09:04.