snapshooter icon indicating copy to clipboard operation
snapshooter copied to clipboard

Extensions for Xunit's Assert and FluentAssertion's ObjectAssertions

Open gmiserez opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. Hi,

We're encountering the following warning in Visual Studio 19 when using Sonar for additional code quality checks. image

The sonar rule is available here: https://rules.sonarsource.com/csharp/RSPEC-2699 As explained in their docu, they check for asserts from the following frameworks:

  • MSTest
  • NUnit
  • XUnit
  • FluentAssertions (4.x and 5.x)
  • NSubstitute

Describe the solution you'd like For Fluent: An Extension Method to assert Snapshots for fluent's ObjectAssertions class would probably do the trick.

myObject.Should().MatchSnapshot()

Note: today this already sort-of works, the OjectAssertions Object gets properly serialized and snapshot and only contains a wrapper around the object that we are actually interested in.

For XUnit's Assert: TBD, probably not easily feasible.

gmiserez avatar Oct 02 '20 13:10 gmiserez

when using

myObject.Should().MatchSnapshot()

the wrapper should no longer be in the snapshot. #57 and #124 are both included in the current version v0.6.0

RohrerF avatar Mar 01 '21 13:03 RohrerF