'Fluent Assertions "Maximum recursion depth was reached…"

I have a number of nested complex objects that I'm attempting to compare with Fluent Assertions with the following code:

restResponse.Should().BeEquivalentTo(mappedSoapResponse, options =>
            {
                options.AllowingInfiniteRecursion();
                options.IgnoringCyclicReferences();
                return options;
            });

Despite this however I keep hitting an issue with "Maximum recursion depth was reached…" despite specially enabling infinite recursion.



Solution 1:[1]

Have you tried adding this beforehand

AssertionOptions.FormattingOptions.MaxDepth = 100;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 chris31389