Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamralph/52d13836dedad92994af to your computer and use it in GitHub Desktop.
Save adamralph/52d13836dedad92994af to your computer and use it in GitHub Desktop.
Example of how to perform nested approximate double comparison in FluentAssertions
var doubleRule = new AssertionRule<double>(
i => i.RuntimeType == typeof(double),
c => Math.Abs(c.Expectation - c.Subject).Should().BeLessThan(0.0000000000001));
actual.ShouldBeEquivalentTo(expected, options => options.Using(doubleRule));
@dennisdoomen
Copy link

Something like this?

var doubleRule = new AssertionRule<double>(
   i => i.RuntimeType == typeof(double),
   c => c.Subject.Should().BeApproxamitelly(c.Expectation, 0.0000000000001));

@adamralph
Copy link
Author

Aha! OK, now I get it. Thanks 😉.

@madstt
Copy link

madstt commented Dec 19, 2014

I'm looking for customizing assertions when comparing lists. The following is using SemanticComparison to compare two objects from two lists:

                entities[0].AsSource().OfLikeness<SomeObject>()
                .OmitAutoComparison()
                .WithDefaultEquality(x => x.SomeProperty1)
                .WithDefaultEquality(x => x.SomeProperty2)
                .ShouldEqual(result[0]);

I'd like FluentAssertions to compare the two lists with some specified options like above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment