Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save adamralph/52d13836dedad92994af to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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
Copy Markdown
Author

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

@madstt

madstt commented Dec 19, 2014

Copy link
Copy Markdown

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