Created
May 8, 2014 09:27
-
-
Save adamralph/52d13836dedad92994af to your computer and use it in GitHub Desktop.
Example of how to perform nested approximate double comparison in FluentAssertions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
Aha! OK, now I get it. Thanks 😉.
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
Something like this?