Releases
Unreleased
What’s new
- New overloads of BeXmlSerializableandBeDataContractSerializablethat allowEquivalencyOptionsto be configured, allowing the use of member selection rules. - #3107
8.8.0
What’s new
- Added WithoutMessageto allow asserting an exception message does not contain a wildcard pattern - #3100
- Added support for MSTest 4 - #3111
Enhancements
- Improved the way the differences are reported for long strings - #3101
8.7.1
Fixes
- Fixed ambiguity when using Should()on aJsonNodederived class - #3102
- JSON assertions did not properly handle floats, doubles and unsigned int/long - #3105
8.7.0
What’s new
- Added support for System.Text.Json.JsonNodeandJsonArraythrough new assertions as well as theBeEquivalentToAPI - #3094
- Added WithoutMessageto allow asserting an exception message does not contain a wildcard pattern - #3100
8.6.0
What’s new
- Add Value.ThatMatchesandValue.ThatSatifiesto build inline assertions when usingBeEquivalentTo- #3076
8.5.0
What’s new
- Add WithStrictTypingandWithStrictTypingFortoBeEquivalentToto ensure types also match - #3066
Fixes
- Ensured WithTracingis safe when used withBeEquivalentToglobally - #3067
8.4.0
Enhancements
- Added ExcludingMembersNamedtoBeEquivalentToto exclude fields and properties anywhere in the graph - #3062
- Added Should().Throw(),ThrowAsync()andThrowWithinAsync()flavors that don’t require a specific exception type - #3059
8.3.0
Enhancements
- Clarify the date/time type when comparing non-compatible dates and times in BeEquivalentTo- #3049
- Improve the rendering of exception messages when using WithMessagefor better readability - #3039
8.2.0
Fixes
- Fixed a regression from 8.1.0 where a NullReferenceExceptionwas thrown during subject identification - #3036
Enhancements
- Better support for rendering multi-dimensional arrays in failure messages - #3009
8.1.1
Fixes
- Fix a formatting exception when {} is used as a dictionary key - #3008
- Removed the PowerShell script that opens the website because it misbehaves - #3030
8.1.0
Improvements
- Improved subject identification when chaining multiple assertions using Which- #3000
- All Should()methods on reference types are now annotated with the[NotNull]attribute for a better Fluent Assertions experience when nullable reference types are enabled - #2987
- Provide a toggle to suppress the soft warning that commercial use requires a paid license - #2984
Fixes
- Fixed a regression in which CompleteWithinAsynctreated a canceled task as an exception - #2853
8.0.0
License Change
Versions 8 and beyond are/will be free for open-source projects and non-commercial use, but commercial use requires a paid license. Check out the license page for more information.
Version 7 will remain fully open-source indefinitely and receive bugfixes and other important corrections.
What’s new
- Introduced a new assembly-level attribute that you can use to initialize Fluent Assertions before the first assertion - #2292
- Ensure compatibility with .NET 8 - #2466
- Add support for NUnit 4 - #2483
- Added NotBeInto check if aDateTimeis not in a givenDateTimeKind- #2536
- Introduced a new Satisfymethod available to all reference types to allow for nested assertions - #2597
- Added BeNaNandNotBeNaNfor assertions onfloatanddouble- #2606
- Added option for event monitoring to ignore failing event accessors - #2629
- Added the capability of associating IValueFormatters to a (nested)AssertionScope- #2676
- Added support for throwing TUnit exceptions when using TUnit as your testing framework - #2758
- Added a few more assertions on XElement- #2690- [Not]HaveElementWithValue
- NotHaveElement
- [Not]HaveAttribute
- NotHaveAttributeWithValue
 
- Added a few more assertions on XDocument- #2690- [Not]HaveElementWithValue
- NotHaveElement
 
- Added support for xUnit.net v3 - #2718
Improvements
- Improve failure message for string assertions when checking for equality - #2307
- Allow specifying EquivalencyOptionsin string assertions - #2413- This also adds the capability to ignore casing, leading or trailing whitespace on strings when using BeEquivalentToon object graphs or collections.
- Also adds the capability to ignore the newline style on strings - #2565
 
- This also adds the capability to ignore casing, leading or trailing whitespace on strings when using 
- You can mark all assertions in an assembly as custom assertions using the [CustomAssertionsAssembly]attribute - #2389
- All Should()methods on reference types are now annotated with the[NotNull]attribute for a better Fluent Assertions experience when nullable reference types are enabled - #2380
- All assertions that support chaining using the .Whichconstruct will now amend the caller identifier - #2539
- Introduced a MethodInfoFormatterand improved thePropertyInfoFormatter- #2539
- Excluding()/- For().Exclude()and- Including()on- BeEquivalentTo()now also accepts an anonymous object to include/exclude multiple members at once - #2488
- You can exclude explicitly implemented properties from BeEquivalentToviaExcludingExplicitlyImplementedProperties- #2851
Fixes
- Fixed incorrect treatment of “\r\n” as new line - #2569
- Fixed RaisePropertyChangeForto return a filtered list of events - #2677
- Including or excluding members did not work when WithMappingwas used inBeEquivalentTo- #2860
- Fix a crash when using WithStrictOrderingFor(x => x)withBeEquivalentTo- #2932
Breaking Changes (for users)
- Moved support for DataSet,DataTable,DataRowandDataColumninto a new packageFluentAssertions.DataSet- #2267
- Removed obsolete ...OrEqualTomethods - #2269- GenericCollectionAssertions- HaveCountGreaterOrEqualTo: Use- HaveCountGreaterThanOrEqualTo
- HaveCountLessOrEqualTo: Use- HaveCountLessThanOrEqualTo
 
- ComparableTypeAssertions- BeGreaterOrEqualTo: Use- BeGreaterThanOrEqualTo
- BeLessOrEqualTo: Use- BeLessThanOrEqualTo
 
- SimpleTimeSpanAssertions- BeGreaterOrEqualTo: Use- BeGreaterThanOrEqualTo
- BeLessOrEqualTo: Use- BeLessThanOrEqualTo
 
- ExecutionTimeAssertions- BeGreaterOrEqualTo: Use- BeGreaterThanOrEqualTo
- BeLessOrEqualTo: Use- BeLessThanOrEqualTo
 
 
- Removed the DefaultValueFormatter.SpacesPerIndentionLevelproperty which was added during the development of v6, but wasn’t removed before the release of v6 - #2281
- Dropped direct support for .NET Core 2.x and .NET Core 3.x - #2302
- AllSatisfynow succeeds when asserting that an empty collection satisfies some predicates - #2321
- OnlyContainnow succeeds when asserting that an empty collection matches some predicates - #2350
- Dropped support for BinaryFormatter- #2278
- Renamed “…AssertionOptions” to “…Options” - #2414
    - EquivalencyAssertionOptionsto- EquivalencyOptions
- EquivalencyAssertionOptions<TExpectation>to- EquivalencyOptions<TExpectation>
- IEquivalencyAssertionOptionsto- IEquivalencyOptions
- SelfReferenceEquivalencyAssertionOptions<TSelf>to- SelfReferenceEquivalencyOptions<TSelf>
 
- Allow fluently calling WithoutMatchingRulesandWithoutSelectionRuleswhile usingBeEquivalentTo- #2457
- Removed utcNowoverload for.Monitor<T>()- #2629
- The semantics of BeLowerCased/BeUpperCasedhave been changed to align with the behavior ofToLower/ToUpper- #2660
- Renamed HaveAttributetoHaveAttributeWithValueonXElement- #2690
- Renamed RespectingRuntimeTypestoPreferringRuntimeMemberTypesandRespectingDeclaredTypestoPreferringDeclaredMemberTypes- #2866
- Renamed ExcludingNestedObjectstoWithoutRecursingto better describe its purpose - #2876
- Removed direct support for assertions on HttpResponseMessage. Use FluentAssertions.Web instead. - #2909
- Consolidated the configuration options under ConfigurationandServicesintoGlobalConfigurationaccessible throughAssertionEngine.ConfigurationandAssertionConfiguration.Current.Configuration- #2901
- Removed support for setting configuration settings through an app.configfile - #2901
Breaking Changes (for extensions)
- Add ForConstrainttoIAssertionsScopeto support chaining.ForConstraint()after.Then- #2324
- Refactored AsyncFunctionAssertionsinto real base class - #2359- Its constructor has been made protected.
- Unused constructors have been removed.
- Methods overwritten in GenericAsyncFunctionAssertionshas been moved toNonGenericAsyncFunctionAssertions.
 
- Its constructor has been made 
- Moved the non-generic NotThrowandNotThrowAfterfromDelegateAssertions<TDelegate, TAssertions>toActionAssertions- #2371
- Made EquivalencyValidatorinternal- #2854
7.2.0
Fixes
- Fixed a regression in which CompleteWithinAsynctreated a canceled task as an exception - #2853
Improvements
- Improve failure message for string assertions when checking for equality - #2307
- All Should()methods on reference types are now annotated with the[NotNull]attribute for a better Fluent Assertions experience when nullable reference types are enabled - #2987
7.1.0
Improvements
- Added compatibility with xUnit.net v3 - #2970
- Added support for throwing TUnit exceptions when using TUnit as your testing framework - #2971
7.0.0
Fixes
- The expectation node identified as a cyclic reference is still compared to the subject node using simple equality - #2819
- Fixed a problem in BeEquivalentTowhere write-only properties would cause aNullReferenceException- #2836
Breaking Changes
- Dropped direct support for .NET Core 2.x and .NET Core 3.x - #2302
- Dropped support for NSpec3test framework - #2356
- Raised dependencies on System.Configuration.ConfigurationManagerto 6.0.0 andSystem.Threading.Tasks.Extensionsto 4.5.4 - #2673 and #2855
Fixes
- Fixed a problem in BeEquivalentTowhere write-only properties would cause aNullReferenceException- #2836
6.12.3
Fixes
- The expectation node identified as a cyclic reference is still compared to the subject node using simple equality - 2819
6.12.2
Fixes
- Better handling of normal vs explicitly implemented vs default interface properties - 2794
6.12.1
Improvements
- Improve BeEmpty()andBeNullOrEmpty()performance forIEnumerable<T>, by materializing only the first item - #2530
Fixes
- Fixed formatting error when checking nullable DateTimeOffsetwithBeWithin(...).Before(...)- #2312
- BeEquivalentTowill now find and can map subject properties that are implemented through an explicitly-implemented interface - #2152
- Fixed that the becauseandbecauseArgswere not passed down the equivalency tree - #2318
- BeEquivalentTocan again compare a non-generic- IDictionarywith a generic one - #2358
- Fixed that the FormattingOptionswere not respected in innerAssertionScope- #2329
- Capitalize trueandfalsein failure messages and make them formattable to a customBooleanFormatter- #2390, #2393
- Improved the failure message for NotBeOfTypewhen wrapped in anAssertionScopeand the subject is null - #2399
- Improved the failure message for BeWritable/BeReadablewhen wrapped in anAssertionScopeand the subject is read-only/write-only - #2399
- Improved the failure message for ThrowExactly[Async]when wrapped in anAssertionScopeand no exception is thrown - #2398
- Improved the failure message for [Not]HaveExplicitPropertywhen wrapped in anAssertionScopeand not implementing the interface - #2403
- Improved the failure message for [Not]HaveExplicitMethodwhen wrapped in anAssertionScopeand not implementing the interface - #2403
- Changed BeEquivalentToto excludeprivate protectedmembers from the comparison - #2417
- Fixed using BeEquivalentToon an emptyArraySegment- #2445, #2511
- BeEquivalentTowith a custom comparer can now handle null values - #2489
- Ensured that nested calls to AssertionScope(context)create a chained context - #2607
- One overload of the AssertionScopeconstructor would not create an actual scope associated with the thread - #2607
- Fixed ThrowWithinAsyncnot respectingOperationCanceledException- #2614
- Fixed using BeEquivalentTowith anIEqualityComparertargeting nullable types - #2648
6.12.0
What’s new
- Added Be,NotBeandBeOneOffor object comparisons with custom comparer - #2111
- Added BeSignedWithPublicKey()andBeUnsigned()for assertions onAssembly- #2207
- Added NotContainItemsAssignableTofor asserting that a collection does not contain any items assignable to a specific type - #2266
Fixes
- becauseand- becauseArgswere not included in the error message when collections of enums were not equivalent - #2214
- Improve caller identification for tests written in Visual Basic - #2254
- Improved auto conversion to enums for objects of different integral type - #2261
- Fixed exceptions when trying to auto convert strings or enums of different type to enums- #2261
- Format records and anonymous objects with their member values instead of the generated ToString- #2144
6.11.0
What’s new
- Added ThrowWithinAsyncfor assertions onTask- #1974
- Added support for converting integers to enums using AutoConversion- #2147
- Changed exception formatting to include any inner exception - #2150
- Added an expression overload for WithoutStrictOrderingFor- #2151
Fixes
- Improved robustness of several assertions when they’re wrapped in an AssertionScope- #2133
- The maximum depth BeEquivalentTouses for recursive comparisons was 9 instead of the expected 10 - #2145
- Fixed .Excluding()and.For().Exclude()not working if root is a collection - #2135
- Prevent InvalidOperationExceptionwhen formatting a lambda expression calling a constructor - #2176
6.10.0
Fixes
- Fixed hanging of CompleteWithinAsyncwhen used withWithResultandAssertionScope- #2101
- BeEquivalentTono longer crashes on fields hiding base-class fields - #1990
- Fixed System.Net.Http dependency declaration for net47 target framework to be a framework dependency instead of a nuget dependency - #2122
6.9.0
What’s new
- Added ThatAre[Not]ValueTypesmethod for filtering the types - #2083
- Added Implymethod toBooleanAssertions- #2074
- Added ThatAre[Not]Interfacesmethod for filtering the types - #2057
- Added ThatAre[Not]Abstractmethod for filtering the types - #2058
- Added ThatAre[Not]Sealedmethod for filtering the types - #2059
- Added ThatAre[Not]Abstractmethods toMethodInfoSelector.csfor filtering the methods - #2060
- Added ThatAre[Not]Abstract,ThatAre[Not]StaticandThatAre[Not]Virtualproperties for filtering inPropertyInfoSelector.cs- #2054
- Added BeOneOfmethods for object comparisons andIComparables - #2028
- Added BeCloseToandNotBeCloseTotoTimeOnly- #2030
- Added new extension methods to be able to write Exactly.Times(n),AtLeast.Times(n)andAtMost.Times(n)in a more fluent way - #2047
- Changed BeEquivalentToto treat record structs like records, thus comparing them by member by default - #2009
Fixes
- PropertyInfoSelector.ThatArePublicOrInternalnow takes the setter into account when determining if a property is- publicor- internal- #2082
- Querying properties on classes, e.g. typeof(MyClass).Properties(), now also includes static properties - #2054
- Nested AssertionScopes now print the inner scope reportables - #2044
- Throw ArgumentExceptioninstead ofArgumentNullExceptionwhen a requiredstringargument is empty - #2023
- Assertions on the ordering of a collection of strings now uses ordinal comparison when anIComparer<T>is not provided - #2075
6.8.0
What’s new
- Added ContainInConsecutiveOrderandNotContainInConsecutiveOrderassertions to check if a collection contains items in a specific order and to be consecutive - #1963
- Added NotCompleteWithinAsyncfor assertions onTask- #1967
- Added CompleteWithinAsyncandNotCompleteWithinAsyncfor non-genericTaskCompletionSource(.NET 6 and above) - #1961
- Added a ParentTypetoIObjectInfoto help determining the parent in a call toUsing/Whenconstructs - #1950
- Added a MonitortoEventAssertionsto enable writing extension methods for event assertions. - #2008
Improvements
- Updated exception messages to provide suggestions when incorrectly using Equals()- #2006
- Included the time difference in the error message of BeCloseTo- #2013
Fixes
- Fixed For/Excludenot excluding properties in objects in a collection - #1953
- Changed MatchEquivalentOfto useCultureInfo.InvariantCultureinstead ofCultureInfo.CurrentCulture- #1985.
- Fixed BeEquivalentTonot taking into account anyrecordequivalency settings coming from theAssertionOptions- #1984
- Fixed ExecutionTimeOfformatting failing when the expression includes {} - #1994
6.7.0
What’s new
- Added BeDefinedandNotBeDefinedto assert on existence of an enum value - #1888
- Added the ability to exclude fields & properties marked as non-browsable in the code editor from structural equality comparisons - #1807 & #1812
- Assertions on the collection types in System.Data (DataSet.Tables,DataTable.Columns,DataTable.Rows) have been restored - #1812
- Added For/Excludeto allow exclusion of members inside a collection - #1782
- Added overload for HaveElementforXDocumentandXElementto assert on number of XML nodes - #1880
Fixes
- Fixed the failure message for regex matches (occurrence overload) to include the missing subject - #1913
- Fixed WithArgsmatching too many events when at least one argument matched the expected type - #1920
6.6.0
What’s New
- Annotated [Not]MatchRegex(string)with[StringSyntax("Regex")]which IDEs can use to colorize the regular expression argument - #1816
- Added support for .NET6 DateOnlystruct - #1844
- Added support for .NET6 TimeOnlystruct - #1848
- Added NotBefor nullable Boolean values - #1865
- Added a new overload to MatchRegex()to assert on the number of regex matches - #1869
- Added difference to numeric assertion failure messages - #1859
Fixes
- EnumAssertions.Bedid not determine the caller name - #1835
- Ensure ExcludingMissingMembersdoesn’t undo usage ofWithMappinginBeEquivalentTo- #1838
- Better handling of NaN in various numeric assertions - #1822 & #1867
- WithMappingin- BeEquivalentTonow also works when the root is a collection - #1858
6.5.1
Fixes
- Fixed regression introduced in 6.5.0 where collection.Should().BeInAscendingOrder(x => x)would fail - #1802
6.5.0
What’s New
- Added AllSatisfyfor asserting all items in a collection satisfy an inspector - #1790
- Added WithMappingoption toBeEquivalentToto map members with different names between the subject and expectation - #1742
Fixes
- Improved the documentation on BeLowerCasedandBeUpperCasedfor strings with non-alphabetic characters - #1792
- Caller identification does not handle all arguments using new- #1794
- Resolved an issue preventing HaveAccessModifierfrom correctly recognizing internal interfaces and enums - #1793
- Improved tracing for nested AssertionScopes - #1797
Fixes (Extensibility)
- Fixed a continuation issue when using ClearExpectation- #1791
6.4.0
What’s New
- Added ThatAreStatic()andThatAreNotStatic()for filtering in method assertions - #1740
- Added new assertions for the HttpStatusCodeof anHttpResponseMessage- #1737
- Added non-generic overloads for WithInnerExceptionExactlyandWithInnerException- #1769
Fixes
- ContainItemsAssignableTonow expects at least one item assignable to- T- #1765
- Querying methods on classes, e.g. typeof(MyController).Methods(), now also includes static methods - #1740
- Variable name is not captured after await assertion - #1770
- OccurredEventordering on monitored object is now done via thread-safe counter - #1773
- Avoid a NullReferenceExceptionwhen testing an application compiled with .NET Native - #1776
- [Not]Contain(key, value)for dictionary-like enumerables incorrectly checked if the key was present - #1786
- Avoid throwing a FormatExceptionwhen caller name determination returns an unformattable string - #1788
6.3.0
What’s New
- Added ThatAreAsync()andThatAreNotAsync()for filtering in method assertions - #1725
- Added ThatAreVirtual()andThatAreNotVirtual()for filtering in method assertions - #1744
- Added collection content to assertion messages for HaveCountGreaterThan(),HaveCountGreaterThanOrEqualTo(),HaveCountLessThan()andHaveCountLessThanOrEqualTo()- #1760
Fixes
- Prevent multiple enumeration of IEnumerables in parameter-lessContainSingle()- #1753
- Changed HaveCount()assertion message order to state expected and actual collection count before dumping its content` - #1760
- CompleteWithinAsyncdid not take initial sync computation into account when measuring execution time - 1762.
6.2.0
What’s New
- Added new overloads to all GreaterOrEqualToandLessOrEqualToassertions, adding the wordThan- #1673
- BeAsync()and- NotBeAsync()are now also available on- MethodInfoSelectorAssertions- #1700
Fixes
- Prevent exceptions when asserting on ImmutableArray<T>- #1668
- Atnow retains the- DateTimeKindand keeps sub-second precision when using a- TimeSpan- #1687.
- Removed iteration over enumerable when generating the BeEmptyassertion failure message - #1692.
- Prevent ArgumentNullExceptionwhen formatting a lambda expression containing an extension method - #1696
- IgnoringCyclicReferencesin- BeEquivalentTonow works while comparing value types using- ComparingByMembers- #1708
- Using BeEquivalentToon a collection with nested collections would complain about missing members - #1713
- Formatting a lambda expression containing lifted operators - #1714.
- Performance improvements in BeEquivalentToby caching expensive Reflection operations - #1719
6.1.0
What’s New
- Prevent asserting directly on AndConstraint- #1649
- Added WithInnerExceptionExactlyextension method onTask<ExceptionAssertions<T>>for easier use withThrowAsync- #1658
Fixes
- Resolved a significant performance degradation in BeEquivalentTo- #1660
6.0.0
What’s New
- Added official support for .NET Core 3.0 - #1227.
- Added WithOffsetextension method onDateTimefor easier creation ofDateTimeOffsetobjects - #1235.
- Added collectionOfStrings.Should().NotContainMatch()to assert that the collection does not contain a string that matches a wildcard pattern - #1246.
- The Using/Whenoption onBeEquivalentTowill now use the conversion rules when trying to match the predicate - #1257.
- Added NotBeWritabletoPropertyInfoSelectorAssertionsto be able to assert that properties are not writable - #1269.
- Added extension to assert TaskCompletionSource<T>- #1267.
- Added the ability to pass an IEqualityComparer<T>throughBeEquivalentTo(x => x.Using<MyComparer>())- #1284.
- Added NotBetoBooleanAssertionsto be able to assert that a Boolean is not the expected value - #1290.
- Make DefaultValueFormatterandEnumerableValueFormattersuitable for inheritance - #1295.
- Added support for dictionary assertions on IReadOnlyDictionary<TKey, TValue>- #1298.
- GenericAsyncFunctionAssertionsnow has- AndWhichConstraintoverloads for- NotThrow[Async]and- NotThrowAfter[Async]- #1289.
- Added ReturnTypestoMethodInfoSelectorto get all return types from all the methods selected
- Added [Not]BetoMethodInfoSelectorto check that methods [don’t] have specified access modifier
- Added ThatAre[Not]Classes,ThatAre[Not]Staticselectors toTypeSelector
- Added ThatSatisfytoTypeSelectorto filter types with specified predicate
- Added UnwrapEnumerableTypestoTypeSelectorto get theTtype from types implementingIEnumerable<T>
- Added UnwrapTaskTypestoTypeSelectorto get theTtype for any type that areTask<T>orValueTask<T>
- Added [Not]BeSealedtoTypeSelectorAssertions
- Added collection.Should().NotContainEquivalentOfto use object graph comparison rules to assert absence of an element in the collection - #1318.
- Added [Not]BeInNamespaceand[NotBeUnderNamespace]toTypeSelectorAssertions- #1329.
- The Usingoption onBeEquivalentToand onAssertionOptions.AssertEquivalencyUsingnow supports customIOrderingRuleimplementations #1337.
- Added AllBetoStringCollectionAssertionsto be able to assert that all strings in collection are equal to the specified string - #1332.
- Added ForConstraintmethod toAssertionScopeto open upOccurenceConstraintfor usage in custom assertion extensions - #1341.
- Added NotContainInOrdertoCollectionAssertionsandStringCollectionAssertionsto be able to assert that the collection does not contain the specified elements in the exact same order, not necessarily consecutive - #1339.
- Added async version of Whereextension method toExceptionAssertionsto be able to check asynchronously thrown exception - #1352.
- Added [Not]BeUpperCasedand[Not]BeLowerCasedtoStringAssertionsto be able to assert that a string is in upper or lower casing or not - #1357.
- Added ObjectAssertions<TSubject, TAssertions>to ease creation of custom assertion classes - #1371.
- Added ComparingBy{Members,Value}(Type)to allow specifying open generic types - #1389.
- Added overload of CollectionAssertions.NotBeEquivalentTothat takes aconfigparameter` - #1408.
- Changed StringAssertions.StartWith,StringAssertions.EndWithand theirEquivalentOfversions to allow empty strings - #1413.
- The equivalency assertions will now include the type of the member and whether it involves a field or property - #1379
- Changed AttributeBasedFormatter to allow custom formatter selection based on the parent type - #1418.
- Added nullable overload for BeandNotBemethods ofDateTimeAssertionsandDateTimeOffsetAssertions- #1427.
- Added overload of Enumeratingextension method to be able to force the enumeration of an object member -#1433
- Add overloads of MatchRegexandNotMatchRegexthat takeSystem.Text.RegularExpressions.Regex-#1436
- Added support for equivalency tests on System.Data types (DataSet,DataTable,DataColumn,DataRow,DataRelation,Constraint) - #1419.
- Added WithParameterNameextension to ease asserting on the parameter name for a thrownArgumentException- #1466.
- Added BeExactlyassertions to verify aDateTimeOffsetexactly, i.e both its date/time and its offset - #1609.
- Added NotCompleteWithinAsynctoTaskCompletionSourceAssertions- #1474.
- Added HaveValue(decimal),HaveSameValueAsandHaveSameNameAstoEnumAssertions- #1479.
- Added WithResultextension method toCompleteWithinAsyncassertions forTask<T>andTaskCompletionSource<T>- #1478.
- Added Satisfyto be able to compare a collection with a set of predicates in any order - #1500.
- Added milliseconds formatting for error messages including TimeSpan- #1504.
- Added AddReportableoverload toAssertionScopefor deferring reportable value calculation only on a test failure - #1515.
- Added the possibility to set the maximum depth and other formatting settings either globally or per AssertionScope- #1469.
- Added BeInAscendingOrderandBeInDescendingOrderfor collections taking a lambda expression - #1526
- Added [Not]BeWritable,[Not]BeSeekable,[Not]BeReadable,[Not]BeReadOnly,[Not]BeWriteOnly,[Not]HaveLength,[Not]HavePositionfor Stream and[Not]HaveBufferSizefor BufferedStream - #1543
- Added native support for XDocument,XElementandXAttributeproperties and fields toBeEquivalentTo- #1572
- The equivalency failure message will include information on how tuples, anonymous types, records and other types are compared - #1571
- Improved formatting a dictionary when key or value is a complex type - #1577.
- Added NotBe(string)for symmetry withBe(string)for GuidAssertions - #1597.
- Added BeOneOffor enum assertions - #1637
- Homogenized assertion message formatting of predicate expressions - #1619.
Fixes
- Reported actual value when it contained {{{{or}}}}- #1234.
- Changed dictionary assertion NotContainKeysto honour the key comparer if applicable - #1233.
- Ensures that date time assertions like “a is less than an hour after b” don’t succeed when a - b == -30.Minutes()#1313.
- Event raising assertions like WithSenderandWithArgswill only return the events that match the constraints - #1321
- Fixed an InvalidCastExceptionthatBeEquivalentTocould throw while debugging - #1325
- Ensured that Givenwill no longer evaluate its predicate if the precedingFailWithraised an assertion failure - #1325
- Improved the message that RaisePropertyChangeForthrows when the wrong property was detected - #1333
- Guard against negative precision arguments for BeCloseToandBeApproximately- #1386
- Guard against implicitly or explicitly trying to compare primitive types by members - #1394.
- Fixed formatting of brackets in expressions passed to ContainSingle(…) - #1406.
- Fixed Contain,NotContainandOnlyContainto avoid multiple enumerations when the condition is false - #1421.
- Added variable name and other useful and consistent information to XML assertions - #1440.
- Sometimes BeEquivalentToreported an incorrect message when a dictionary was missing a key - #1454
- Some dictionary failures did not honor the user-provided reason - #1456
- Restrict what types WhenTypeIs<T>can use and howUsing<T>handles non-nullable types, see the Migration Guide for more details - #1494.
- HaveElementdid not ignore the xml namespace - #1541
- Better parameter checking of TypeAssertions- #1550
- [Not]HaveExplicitMethoddid not mention the parameters in the failure message - #1550
- Better parameter checking of PropertyInfoAssertions- #1558
- Better parameter checking of MethodBaseAssertionsandMethodInfoAssertions- #1559
- Better parameter checking of AssemblyAssertions- #1561
- Better parameter checking of PropertyInfoSelectorAssertions- #1565
- Better parameter checking of MethodInfoSelectorAssertions- #1569
- Better parameter checking of XDocumentAssertions,XElementAssertionsandXAttributeAssertions- #1564
- In a chained assertion API call, a second call to ForConditionshould not even evaluate its lambda when the previous assertion failed - #1587
- Added parameter checking for Be(string)for GuidAssertions - #1597.
- Improved consistency of XML documentation on AssertionScope,ContinuedAssertionScope, andGivenSelector<T>methods. - #1606.
- Handle WithDefaultIdentifierandWithExpectationcorrectly when anAssertionScopecontinues - #1610.
- Improved stack trace when a property of an element of a generic collection throws an exception during GenericEnumerableEquivalencyStepinGenericCollectionAssertions- #1615.
- Removed the type info from the failure message in equivalency checks - #1621.
- Fixed a regression so that collections of similarly typed key-value pairs should be equivalent to a dictionary - #1603.
- Fixed a regression where a nested class without suitable members inside a collection raised an exception - #1627.
- Fixed support for covariant and inherited property exclusion and inclusion in BeEquivalentTo- #1631.
- Reintroduced Matchfor enum assertions - #1637
- Improved caller name determination by supporting multiple lines, comments and semicolons - #1435.
Breaking Changes
- Dropped support for .NET Framework 4.5, .NET Standard 1.3 and 1.6 - #1227.
- Dropped support for older test frameworks such as MSTest v1, NSpec v1 and v2, XUnit v1, Gallio and MBUnit - #1227.
- Removed [Not]Have{Im,Ex}plictConversionOperator(they had typos) - #1221.- Use the equivalent assertions without the typo “plict” instead.
 
- Removed NotBeAscendingInOrder/NotBeDescendingInOrder- #1221.- Use NotBeInAscendingOrder/NotBeInDescendingOrderinstead.
 
- Use 
- Removed HasAttribute,HasMatchingAttributeandIsDecoratedWith(Type, bool)Typeextensions - #1221.- Use IsDecoratedWith/IsDecoratedWithOrInheritsinstead.
 
- Use 
- Made EquivalencyAssertionOptionsExtentionsinternal(and fixed a typo in the type name) - #1221.
- Changed ReferenceTypeAssertions.Subjectto bereadonly- #1229.- Set the Subjectthrough the constructor instead.
 
- Set the 
- Changed TypeAssertions.HaveAccessModifierreturn type fromAndConstraint<Type>toAndConstraint<TypeAssertions>- #1159.
- Changed TypeAssertions.NotHaveAccessModifierreturn type fromAndConstraint<Type>toAndConstraint<TypeAssertions>- #1159.
- Changed AllBeAssignableTo<T>andAllBeOfType<T>return type fromAndConstraint<TAssertions>toAndWhichConstraint<TAssertions, IEnumerable<T>>- #1265.
- The new extension on TaskCompletionSource<T>overlays the previously used assertions based onObjectAssertions.
- Removed [Not]BeCloseToforDateTime[Offset]andTimeSpanthat took anint precision- #1278.- Use the overloads that take a TimeSpan precisioninstead.
 
- Use the overloads that take a 
- Aligned strings to be compared using Ordinal[Ignorecase]- #1283.
- Changed AutoConversionto convert usingCultureInfo.InvariantCultureinstead ofCultureInfo.CurrentCulture- #1283.
- Renamed StartWithEquivalentandEndWithEquivalenttoStartWithEquivalentOfandEndWithEquivalentOfto make the API for Equivalent methods consistent - #1292.
- Several event raising assertion APIs will return an IEventRecordinginstead ofIEventRecorder- #1321
- The classes EventMonitorandRecordedEventare now treated asinternalcode - #1321
- Renamed method GetEventRecorderof interfaceIMonitortoGetRecordingForand will returnIEventRecording- #1321
- Removed synchronous assertions on asynchronous operations (Throw,NotThrow,CompleteWithin, …) #1324
- Do not modify SynchronizationContext.Currentwhile asserting asynchronous operations. In case hitting deadlocks in your tests please check whether you mix synchronous and asynchronous operations. #1324
- Moved [Not]HaveFlagfromObjectAssertionstoEnumAssertions- #1375.
- Requesting an unsupported test framework via Services.Configuration.TestFrameworkNameor"FluentAssertions.TestFramework"now throws an exception instead of using the fallback - #1366.
- Guard [Not]Match,[Not]MatchEquivalentOf,[Not]MatchRegexand[Not]ContainMatchagainstnullor empty patterns - #1401.
- Renamed WhichValuetoWhoseValue- #1581
- By default, records are now compared by their members. Can be overridden using ComparingRecordsByValue- #1571
- Changed becauseArgsof[Not]Reference(Assembly)fromstring[]toobject[]- #1459
- Major overhaul on how enums are handled, see the Migration Guide for more details - #1479.
- Removed support for non-generic collections, see the Migration Guide for more details - #1529.
- Removed [Not]Contain(IEnumerable<T>, params T[])- #1529.
- Removed BeEquivalentTo(params object[])- #1529.
- Renamed EquivalencyStepCollectiontoEquivalencyPlanandAssertionOptions.EquivalencyCollectiontoEquivalencyPlan- #1539.
- BeEquivalentTowill no longer include- internalproperties and fields, unless- IncludingInternalPropertiesor- IncludingInternalFieldsis used - #1575.
- Renamed protectedmethods onDelegateAssertionsBasesuch asThrowandNotThrowto avoid confusion - #1642
- Moved the properties of IMemberInfo.SelectedMemberInfotoIMemberInfo. RenamedIMemberInfo.SelectedMemberPathtoPathand replacedSelectedMemberDescriptionby a combination ofPathandName- #1379
- Changed [Not]Beon anIComparable<T>to useEquals(object)instead ofCompareTo(T)and added[Not]BeRankedEquallyToto useCompareTo(T)- #1177.
Breaking Changes (Extensibility)
- Removed parameterless constructors from: CollectionAssertions,ReferenceTypeAssertions,MemberInfoAssertions,MethodBaseAssertionsandMethodInfoAssertions- #1229.- Use the constructors taking a subjectinstead.
 
- Use the constructors taking a 
- Restrict generic constraints on [Nullable]NumericAssertions<T>toIComparable<T>- #1266.
- Changed return type of [Nullable]NumericAssertions.SubjectfromIComparabletoT?andT, respectively - #1266.
- Removed SucceededandSourceSucceededfromContinuationandIAssertionScope- #1325
- Made the extension methods under the FluentAssertions.Commonnamespaceinternal- #1376
- The IEquivalencyValidationContexthas undergone significant refactorings where its properties have been moved into theINodehierarchy and the twoReasonandTracerclasses - #1379
- The IMemberMatchingRule,IMemberSelectionRuleandIOrderingRulehave been changed to replace their dependency onSelectedMemberInfotoINodeand its derivativesIMember- #1379
- The SelectedMemberInfoclass has been removed, since it main user,IMemberInfohas been flattened - #1379
- Several methods that took an IMemberInfo, but could also act on other objects than a property or field now take anIObjectInfo- #1379
- Pascal cased CallerIdentifier.logger- #1458.
- Pascal cased SelfReferenceEquivalencyAssertionOptions.orderingRules- #1458.
- Moved extension methods on ExceptionAssertionsfromAssertionExtensionstoExceptionAssertionsExtensions- #1471.
- Moved Including(Expression<Func<IMemberInfo, bool>> predicate)fromEquivalencyAssertionOptions<T>toSelfReferenceEquivalencyAssertionOptions<T>- #1495.
- Formatter.ToString()and- IValueFormatternow work with a- FormattingOptionsobject that wraps the- UseLineBreaksoption - #1469.
- Split-up the subject and expectation from IEquivalencyValidationContextinto a new typeComparands. This affectedIEquivalencyStep- #1539.
- Moved the responsibility of IEquivalencyStep.CanHandleintoHandleand replacedHandle’s return value with a more clearerEquivalencyResult- #1539
- Simplified MemberSelectionContextwhich is used byIMemberSelectionRuleto remove the need for extensions to understand the difference between run-time and compile-time types - #1539.
- The implementations of IEquivalencyStephave moved to theFluentAssertions.Equivalency.Stepsnamespace - #1588.
5.10.3
Fixes
- Fixed XPath index calculation in XML comparison when child node names are repeated in repeated parent nodes - #1273
5.10.2
Fixes
- Added missing dependency on System.Xml - #79
5.10.1
This version was skipped.
5.10.0
What’s New
- Added string.Should().NotBeEquivalentTo- #1134
- Added collectionOfStrings.Should().ContainMatch()to assert that the collection contains at least one string that matches a wildcard pattern - #1138
- Added overloads of NotBeInAscendingOrderandNotBeInDescendingOrderthat take a property expression - #1140
- Include the index in the XPath information reported while comparing XDocuments for equivalence - #1181
- Added NotHaveSameCountandHaveSameCountfor dictionary assertions - #1178
- Extended string.Should().Contain()andstring.Should().ContainEquivalentOf()to test the number of times a phrase exists in a string usingtheString.Should().Contain("is a", MoreThan.Thrice())- #1145
- Added support for methods returning ValueTaskandValueTask<T>- #1158
- Added support for using SatisfyRespectivelyon all collections, including collections ofstring- #1201
Fixes
- Updated the docs to clarify that CompleteWithinworks onFunc<Task>and not onTaskdirectly - #1127.
- Renamed collection assertion NotBeAscendingInOrderandNotBeDescendingInOrdertoNotBeInAscendingOrderandNotBeInDescendingOrder(in a non-breaking way) - #1140
- Collections containing nulls where not properly treated as equivalent byBeEquivalentTo- #1143
- BeEquivalentTonow allows selecting an explicit interface member over a regular instance member when using- RespectingDeclaredTypesand the expectation type is an interface - #1144
- Fixed a crash that can occur when trying to determine the caller identity under .NET Native - #1149
- Ensured that determining the caller identity works for namespaces that contain the phrase Systemand don’t match on partial namespace segments - #1193
- BeEquivalentToon an- XDocumentcould report the incorrect path to a self-closing XML tag - #1170
- BeEquivalentToon multi-dimensional arrays with empty elements could cause an internal error - #1167
- Several assertion APIs did not include the reason in the failure messages - #1172
- A self-closing XML element was not treated as equivalent to an empty element with the same name - #1174
- Ensure that type assertion ThatAreUnderNamespacehandles types in the global namespaces correctly - #1197
- When comparing whether two objects are equal, a conversion should be precision preserving - #1202
- BeEquivalentToon normal- Tuples should use structural equivalency instead of treating them as value types - #1206
- Some platforms throw reflection exceptions when trying to use ConfigurationManager. This is now handled more gracefully - #1210
- Reintroduced the package dependency on System.Xml.Linqfor .NET 4.5/4.7 - #79
- Treat enums and their numeric representations in structural object graph comparisons the same - #1208
Thanks to contributors Ronald Kroon, Daniel Petrov, @david-a-jetter, Lukas Grützmacher and Ben Randall.
And special thanks to Matthias Koch to switch us over to the awesome Nuke build system.
5.9.0
What’s New
- Added Matchmethod to (nullable) numeric assertions - #1112
Fixes
- Using a custom IAssertionStrategywith anAssertionScopedid not always capture all assertion failures - #1118
- Ensured nullarguments are handled with clearer exception messages - #1117
Special thanks to contributors @liklainy and Amaury Levé.
5.8.0
What’s New
- Added thread-safety to tests using AssertionScopewhile running manyasynctests concurrently - #1091
- Allow users to specify a custom IAssertionStrategyfor the assertion scope, for instance, to create screenshots when a test fails - #1094 & #906.
- Supports .NET Core 3.0 Preview 7 - #1107
Fixes
- Excludingwith- BeEquivalentTodid not always work well with overridden properties - #1087 & #1077
- Failure message formatting threw a FormatExceptionwhen a nested message contains braces - #1092
- Fixed confusing (Not)BeAssignableTofailure messages - #1104 & #1103
- Fixed a potential leakage of failure messages between multiple assertions - #1105
Kudos to conklinb and Amaury Levé for notable contributions and my partner-in-crime Jonas Nyrup for some of the fixes, a lot of (internal) quality improvements and his critical eye.
5.7.0
What’s New
- Added official support for .NET Core 3 (Preview 5 or later) - #1057
- Introduced SatisfyRespectivelyon collections - #1043
- Added an alternative fluent syntax for evaluating/invoking actions - #1017
- Added overloads of InvokingandAwaitingfor different sets of generic parameters - #1051
- NotThrowAfteris now also available for .NET Standard 1.3 and 1.6 - #1050
- Added CompleteWithinto assert asynchronous operations complete within a time span - #1013/#1048
- Added NotBeEquivalentfor objects - #1071
- Added WithMessage()forasyncexception assertions - #1052
- Added extension methods like 100.Nanosecond()and20.Microsecond()to represent time spans - #1069
Fixes
- AllBeAssignableToand- AllBeOfTypedid not work for list of types - #1007
- Backslashes in subject or expected result were not correctly shown in the message - #986
- BeOfTypedoes not attach to the- AssertionScopecorrectly - #1002
- Event monitoring did not detect events on interfaces - #821
- Fix continuation on NotThrow(After)in chainedAssertionScopeinvocations - #1031
- Allow nesting equivalency checks in custom assertion rules when using BeEquivalentTo- #1033
- Removed redundant use of the thread pool in async assertions - #1020
- Improved formatting of multidimensional arrays - #1044
- Better handling of exceptions wrapped in AggregateExceptions - #1041
- Fix BadImageFormatExceptionunder the .NET Core 3.0 Preview - #1057
- ThrowExactlyand- ThrowExactlyAsyncnow support expecting an- AggregateException- #1046
Kudos to Lukas Grützmacher, Matthias Lischka, Christoffer Lette, Ed Ball, David Omid, mu88, Dmitriy Maksimov and Ivan Shimko for the contributions and Jonas Nyrup to make this release possible again.
5.6.0
Fixes
- Provide opt-out to AssertionOptions(o => o.WithStrictOrdering())-#974
- Add collection assertion ContainEquivalentOf- #950
- Add Should().NotThrowAfterassertion for actions - #942
Kudos to @BrunoJuchli, @matthiaslischka and @frederik-h for these amazing additions.
5.5.3
Fixes
- Performance fixes in BeEquivalenTo- #935
- Reverted 5.5.0 changes to AssertionScopeto ensure binary compatibility - #977
5.5.2
Fixes
- Allows BeEquivalentToto handle a non-generic collection as the SUT - #975, #973
- Optimized performance of IncludeMemberByPathSelectionRule- #969
5.5.1
What’s New
- Now provides a hint when strings differ in length and contain differences - #915, #907
- Added ThrowAsync,ThrowExactlyAsyncandNotThrowAsync- #931
- Added support for Should().ThrowandShould().NotThrowforFunc<T>- #951
- Added support for private protectedaccess modifier - #932
- Updated BeApproximatelyto support nullable types for both the subject and the expectation nullable - #934
- Added asyncversion ofExecutionTimeto - #938
- Updated NotBeApproximatelyto accepting nullable subject and expectation - #939
- type.Should().Be(type)now support open generics - #954, #955
Fixes
- Minor performance improvements to prevent rendering messages if a test did not fail - #921, #915
- Improve performance of Should().AllBeEquivalentTo()- #920, #914
- Improve the presentation of enums to include the value and the number - #923, #897
- BeEquivalentTowith- WithStrictOrderingproduced messy failure message - #918
- Fixes detecting checking equivalency of a nullsubject to a dictionary - #933
- Fixes duplicate conversions being mentioned in the output of the equivalency API - #941
- Comparing an object graph against IEnumerablenow works now as expected - #911
- Selecting members during object graph assertions now better handles newoverrides - #960, #956
Note In versions prior to 5.5, FA may have skipped certain properties in the equivalency comparison. #960 fixes this, so this may cause some breaking changes.
Lots of kudos @jnyrup and @krajek for a majority for the work in this release.