4.19.2

07 March 2017

  • {Fix} HaveDefaultConstructor throws InvalidOperationException if the type has both a default constructor and a static constructor - #540

4.19.0

04 February 2017

  • {Fix} Adapted the TimeSpan formatter to support time spans between 0.1 microseconds and 1 millisecond - #513
  • {Change} JTokenAssertions.BeEquivalentTo now formats the JSON document in a more readable fashion - #453
  • {New} Allow asserting raised events for event handlers not based on EventArgs - #30
  • {New} Added support for BeOfType and NotBeOfType for value type objects - #459
  • {New} Added support for non-array indexers in member paths when using ShouldBeEquivalentTo - #529
  • {New} Introduced a tracing API to better diagnose structural equivalency assertion errors - #532
  • {Fix} A single string mismatch resulted in two different failures - #340

4.18.0

04 December 2016

  • {New} Ensured that the assembly assertions also include those inherited from ReferenceTypeAssertions - #501
  • {New} Added regular expression annotations for Should().MatchRegex() and Should().NotMatchRegex() to get syntax highlighting and error analysis - #511
  • {New} Added AllBeOfType and AllBeAssignableTo to the collection assertions - #428
  • {New} Added BeNull/NotBeNull as an alternative for HaveValue/NotHaveValue for nullable built-in value type - #495
  • {Fix} Asserting the actual exception thrown by an async block now properly unwraps the superfluous AggregateException - #496
  • {Fix} Ensures FA doesn’t treat standard .NET exception types as value types during a structural equivalency check - #485

4.17.0

09 November 2016

  • {Changed} ContainSingle will list the actual items in the enumerable upon failure - #346
  • {New} Added Jetbrains’ ReSharper attributes to mute certain compiler warnings - #499

4.16.0

26 October 2016

  • {New} Added new Should().BeIn(DateTimeKind) extension to assert that DateTime objects are in the expected kind (Utc, Local or Unspecified) - #492
  • {New} Added AsLocal and AsUtc extensions to fluently specify the DateTimeKind when creating date time values - #492

4.15.0

11 October 2016

  • {New} Added non-generic BeAssignableTo to reference type and Type assertions - #483
  • {New} Added support for MSTest V2. It supports .Net 4.5+, UWP and dotnet core - #486
  • {Changed} When rendering a byte array, it will always use a hexadecimal representation - #487
  • {Fix} Switch underlying type comparison of enums to use decimal rather than long - #470
  • {Fix} Fixed potential deadlocks in async/await exception assertions - #484
  • {Fix} While rendering arrays and collections, the output is limited to 32 elements - #487
  • {Fix} A cyclic reference pointing to the root of a graph was not detected as such - #488

4.14.0

05 September 2016

  • {Changed} Added because parameters to ShouldThrowExactly and ShouldThrow - #456
  • {Changed} Added support for open generic types to Should().BeOfType - #458

4.13.1

01 September 2016

  • {Fix} Ensure failure with a good message if ShouldBeEquivalentTo compares dictionaries against null - #469
  • {Fix} When including an expression-based property using ShouldBeEquivalentTo it should start evaluation at the root - #462
  • {Fix} Fixed an exception that was caused when a compared string contains reserved characters - #465

4.13.0

02 August 2016

  • {Changed} Numbers are now formatted in such a way that their type is visible. Floating point numbers are formatted with their full precision - #445 - @IharBury
  • {New} Add overloads to the collection assertions that accept a custom IComparer<object> object - #451 - @TaffarelJr
  • {Fix} NotBeOfType threw an InvalidCastException - #443

4.12.0

15 July 2016

  • {New} @jeroenpot added BeOneOf to DateTime and DateTimeOffset assertions - #440
  • {Changed} @onovotny added support for NetStandard 1.3 - #442
  • {Fix} @thomaslevesque fixed the unnecessary enumerations of IEnumerable<T> collections - #438

4.11.0

06 July 2016

  • {Change} Added explicit extension methods for JSon.NET to disambiguate between JTokenAssertions and ObjectAssertions - #402 and #405

4.10.0

05 July 2016

  • {New} @MortenBoysen added NotContain(s) overloads to the collection and dictionary assertions - #432

4.9.1

23 June 2016

  • {Fix} ContainSingle didn’t honor the reason - #425

4.9.0

13 June 2016

  • {New} Added negating overloads to the DateTimeOffset assertions - #418

4.8.0

07 June 2016

  • {New} Added inverse methods (a.k.a. Should().NotXxxx) to all DateTime assertions - #414
  • {New} Added ability to reset event monitoring - #417

4.7.0

06 June 2016

  • {New} Added support for NotBeOfType - #413
  • {New} Added extension methods on ISubjectInfo for checking setter and getter access modifiers - #331
  • {New} Added properties for the access modifier of getter and setter on SelectedMemberInfo - #331
  • {Fix} NullReferenceException occurred from ShoulddotThrow when exception doen not have the expected inner exception - #415

4.6.3

24 May 2016

  • {Fix} Structurally comparing null-valued enums by value didn’t include the property path.

4.6.2

22 May 2016

  • {Fix} Structurally comparing null-valued enums by value causes unexpected results - #409 #388

4.6.1

13 May 2016

  • {New} Added Json project & specs - #403

4.6.0

12 May 2016

4.5.0

25 April 2016

  • {New} Added BeDataContractSerializable - #396

4.4.0

17 April 2016

  • {New} Extended the semantic equivalency API that was introduced in 4.2.0 with support for XDocument and XElement - #386
  • {New} Added support for assertions on XmlElement and XmlNode - #392
  • {New} Allowed structurally comparing all elements of a collection against a single object using ShouldAllBeEquivalentTo - #385

4.3.2

03 April 2016 {Fix} Ensured that the xUnit 2 assembly is loaded explicitly - #373

4.3.1

01 April 2016

  • {Fix} Comparing two empty collections resulted in a weird failure fixes - #382.

4.3.0

31 March 2016

  • {New] Added support for semantically comparing XML nodes and documents using node.Should().BeEquivalentTo(node) - #356
  • {New} Added an overload to collection.Should().StartWith and EndWith that supports a sequence of elements - #374
  • {Fix} Ensured that user equivalency steps run before all the built-in steps - #360
  • {Changed} Date times with offset will now include the offset in the failure message - #359

4.2.2

06 February 2016

  • The ComparingByValue<T> option didn’t work when comparing two collections using ShouldAllBeEquivalenTo.

4.2.1

10 January 2016

4.2.0

08 January 2016

  • Added datetime.Should().BeSameDateAs() - #319 (by @blairconrad)
  • Added overloads to dictionary.Should().Contain() and NotContain that take an enumerable of KeyValuePairss - #342 (by @jbattermann)
  • Ensured that ShouldBeEquivalentTo will only include properties which name is an exact match - #329
  • dictionary.ContainKeys(..) had a non-optional because argument and so did ContainValuesAndWhich - the later for reasonArgs which was/is inconsistent with the rest - #333 (by @jbattermann)
  • Added an overload to MonitorEvents to monitor events for implemented interfaces or base classes only - #330 (by @gstamac)

4.1.1

13 December 2015

  • Event monitoring will now work in multi-threaded unit test frameworks such as XUnit 2 (#320)

Fluent Assertions 4.1.0

24 November 2015

  • Ensured that projects targeting win81 or wpa81 don’t use the ‘dotnet’ profile (#295 and #311)
  • Introduced the equivalency option WithoutStrictOrderingFor to specify that certain collection properties should not compared using strict ordening (#306)
  • Added NotBeDecoratedWith attribute assertion (#300)
  • Extended collection.Should().Equal() to support comparing different types of collection using a predicate (#297)

Fluent Assertions 4.0.1

21 October 2015

  • Fixes failure when reasonArgs contain “{“ or “}” (#301)
  • Fixes failure of string assertions when using “{“ and “}” (#287)

Fluent Assertions 4.0.0

07 August 2015

  • Adds support for .NET 4.6, CoreCLR, .NET Native and Universal Windows Apps for Windows 10
  • Removes support for Windows 8.0
  • Removes v3 code that was marked as [Obsolete]:
    • StringCollectionAssertions.Contains(IEnumerable<string>, string)
    • StringCollectionAssertions.Contains(IEnumerable<string>, IEnumerable<string>)
    • CollectionMemberSubjectInfo.PropertyInfo, PropertyPath, PropertyDescription
    • EquivalencyAssertionOptions.Empty and Default which are replaced by the AssertionOptions class
    • IMatchingRule, which is replaced by IMemberMatchingRule
    • ISelectionRule, which is replaced by IMemberSelectionRule
    • ISubjectInfo no longer has properties for getting information about properties since that was replaced with the more general member properties.
    • SelfReferenceEquivalencyAssertionOptions no longer has methods to include/exclude properties, but provides methods for selecting members instead.

Fluent Assertions 3.5.0

03 August 2015

  • #271 - Added a large number of assertions to verify the assembly and type structure in unit tests (piotrpMSFT)
  • #200 - Added an alternative to Which named Subject
  • #285 - Added null-check for when Subject is null in numeric assertions (sietsevdschoot)

Fluent Assertions 3.4.1

03 July 2015

  • #282 - Fixed a stack overflow issue while determining the compile-time type … contributed by Dennis Doomen (dennisdoomen)
  • #281 - Enabled the use of Including() with a nested property expression. contributed by Dennis Doomen (dennisdoomen)

Fluent Assertions 3.4.0

22 June 2015

  • #273 - Added support for recursively comparing two multi-dimensional arrays … contributed by Dennis Doomen (dennisdoomen)
  • #269 - ShouldAllBeEquivalentTo/options.Including does not work as expected
  • #268 - Add serialization constructor for AssertionFailedException contributed by Florian Wittmann (florianwittmann)
  • #264 - Problem with BeOfType and IReadOnlyList
  • #262 - Add serialization constructor for AssertionFailedException contributed by Florian Wittmann (florianwittmann)
  • #261 - Resolve FailWith overload resolution when only constant-string is passed contributed by Helge Jensen (slogen)
  • #260 - ShouldBeEquivalentTo does not detect difference in multi-dimensional array +enhancement
  • #259 - Fixed a bug where ExcludingNestedObjects didn’t work when combined with … contributed by Dennis Doomen (dennisdoomen)
  • #258 - .ShouldBeEquivalentTo() with a tree type leads to infinite loop +fix
  • #253 - Ensured an enum assertion is done when the expectation is an enum during… contributed by Dennis Doomen (dennisdoomen)
  • #252 - Makes EquivalencyAssertionOptionsExtentions.GetSubjectType public contributed by Adam Voss (vossad01)
  • #250 - Added support for HaveFlag and NotHaveFlag contributed by Alexander Endris (AlexEndris)
  • #247 - ShouldBeEquivalentTo between an Enum and Int +fix
  • #246 - Use a better expression formatter
  • #245 - ShouldAllBeEquivalentTo with Including still compares all properties +fix
  • #244 - Changed the equivalency assertion so that comparing a collection with a … contributed by Dennis Doomen (dennisdoomen)
  • #243 - Split the DateTime and DateTimeOffset assertions contributed by Dennis Doomen (dennisdoomen)
  • #241 - ArgumentOutOfRangeException when comparing DateTime.MaxValue or DateTime.MinValue with BeCloseTo()
  • #240 - Changes the encoding of ‘Build/default.ps1’ to UTF-8 contributed by Adam Voss (vossad01)
  • #233 - TargetInvocationException on ShouldAllBeEquivalentTo when class has IReadOnlyList property and its null +fix
  • #194 - ShouldAllBeEquivalentTo and Excluding is not working properly +fix

Important ShouldBeEquivalentTo contained a bug that was causing false positives. If you are experiencing failing unit tests after upgrading to v3.4.0, make sure you use the IncludingAllRuntimeProperties option to include the run-time properties and not just the ones declared.

Fluent Assertions 3.3.0

18 February 2015 New features

  • Added CompareEnumsAsString and CompareEnumsAsValue to the options taken by ShouldBeEquivalentTo so specify how enumerations are compared.
  • Added ShouldThrowExactly and WithInnerExceptionExactly to assert a specific exception was thrown rather than the default of allowing sub-classes of those exceptions. #176
  • Introduced a new static AssertionOptions class that can be used to change the defaults used by ShouldBeEquivalentTo, alter the global collection of IEquivalencySteps that are used internally, and change the rules that are used to identify value types. #134
  • ShouldBeEquivalentTo will now also include public fields. Obviously, this can be changed using a set of new members on the EquivalencyAssertionOptions<T> class that the equivalency API takes.
  • Extended the collection assertions with StartWith, EndWith, HaveElementPreceding and HaveElementSucceeding.
  • Added methods ThatAreDecoratedWith, ThatAreInNamespace, ThatAreUnderNamespace, ThatDeriveFrom and ThatImplement to filter types from assemblies that need to comply to certain prerequisites.
  • Added BeAssignableTo that directly apply toType objects.

Minor improvements and fixes

  • Extended the time-conversion convenience methods with 4.Ticks()
  • When an object implements IDictionary<T,K> more than once, ShouldBeEquivalentTo will fail rather than pick a random implementation. Likewise, if a dictionary only implements IDictionary<,> explicitly, it will still be treated as a dictionary. Finally, ShouldBeEquivalentTo will now respect the declared type of a generic dictionary.
  • A null reference in a nested collection wasn’t properly detected by ShouldBeEquivalentTo.
  • Corrected the remaining cases where ShouldBeEquivalentTo did not respect the declared type. #161
  • Adding an overload to collection.ContainSingle() having no arguments.
  • Included the timezone offset when displaying a DateTimeOffset. #160
  • collection.Should().BeEmpty() now properly reports the collection items it found unexpectedly. #224
  • Made the fallback AssertFailedException serializable to help in certain cross-AppDomain unit tests. #214
  • Better support for rendering the TimeSpan’s MinValue and MaxValue without causign stack overflow exceptions. #212
  • Fixed an issue where the Windows 8.1 test framework detection code would ran into a deadlock when using a [UITestMethod]. #223
  • Fixed an issue where ShouldBeEquivalentTo would throw an internal exception on a unset byte[] property. #165

Internal changes

  • We now use StyleCop to improve the quality level of the code.
  • The first steps have been taken to deprecate IAssertionRule.
  • The internal assertion API has been changed to allow chaining complex assertions using a fluent API. This should make it a lot easier to extend Fluent Assertions. You can read more about that in this blog post
  • We’ve started to use Chill to improve the readability of the more behavioral unit tests.

Fluent Assertions 3.2

13 October 2014 Improvements and bug-fixes

  • Added an extension to fluently await an async method through the new Awaiting method. See the specs for some examples.
  • Improved the message displayed when the object upon which a structural equivalency check is done doesn’t expose any properties that match the selection rules (#22).
  • Corrected the behavior of equivalency assertions on arrays typed as object.
  • The equivalency check would complain about a missing interface-provided property if both subject and expectation implement the interface explicitly (#150).
  • Removed de-duplication of assertion failures because it causes more confusion (#151).
  • Added the possibility to include a property in the equivalency assertion based on a predicate (#154).
  • Ensured that custom formatters are not overwritten by platform specific formatters and added a method to remove a custom formatter from the Formatters collection (#155).

Potentially breaking change

  • Because of changes required for fixing #155, the Formatters collection is no longer directly editable. Instead, use the Formatters.AddFormatter and ‘RemoveFormatter’ methods.

Fluent Assertions 3.1

06 February 2016 Improvements and bug-fixes

  • Added support for Windows Phone 8.1, Windows 8.1 and Universal Apps.
  • Added support for XUnit 2. (#136)
  • Introduced a new syntax for ensuring an assembly doesn’t reference a particular other reference, e.g. assemblyB.Should().NotReference(assemblyA).
  • Reintroduced support for .NET 4.0 rather than requiring .NET 4.0.3. (#121)
  • Ensured that the Which chaining syntax will throw a clear exception if the object that is chained upon doesn’t return a single item. (#99)
  • Added an overload for collection.Should().Equal() that takes a params T[] which should resolve some overload-resolution issues. (#110)
  • Ensured consistent behavior of ShouldBeEquivalentTo on (publicly) member-less objects
  • Fixed DateTime to DateTimeOffset conversions that are close to the edges. (#120)
  • Changed the failure message for ShouldThrow<T> so that it always includes the type of the thrown exception. (#122)
  • Ensured that collection.Should().BeEmpty() does not enumerate the sequence twice. (#124)
  • Excluded indexer properties during a structural equivalency assertion. (#130)
  • Fixed the internal resolution of platform-specific services from the PCL assembly so that custom extensions to FA won’t throw null-reference exceptions. (#126, #119)
  • Ensured that exceptions that implement IEnumerable<T> are still formatted as exceptions. ( #122).
  • The time span assertions that asserted the difference between to dates and times didn’t properly handle UTC. (#127)

Potentially breaking change

  • Due to a long-standing internal bug, ShouldBeEquivalentTo and ShouldAllBeEquivalentTo were using the run-time type of nested objects rather than the compile-time type. So if you suddenly encounter failing unit tests after upgrading to v3.1 consider adding the IncludingAllRuntimeProperties option.

Fluent Assertions 2.2

30 December 2013 New functionality  

  • Gregor Stamac extended the XML assertions with the methods BeEquivalentTo and NotBeEquivalentTo to perform a deep comparison between two XML fragments. 
  • Vossad01 added a Be overload to the NullableSimpleTimeSpanAssertions which allows Be assertions against a nullable TimeSpan (#5).
  • He also added NotBeNullOrWhiteSpace to the string assertions and marked the old BeBlank and NotBeBlank as [Obsolete] (#7).
  • ClockworkPenguin extended the string assertions with MatchRegex and NotMatchRegex methods (#11).
  • We now support the PCL version of NUnit when used in a Windows Store class library serving as a unit test container.
  • Added an overload to BeBinarySerializable that can be used to tweak the internal comparison between the original and the deserialized objects based on the EquivalencyAssertionOptions of the object graph comparison API. (#16)
  • Added NotBeTrue and NotBeFalse assertions for (nullable) booleans.
  • Added BeCloseTo as an assertion on a TimeSpan, similarly to what already exists for DateTimes. (#45)
  • Added the possibility to disable recursion during an object graph equivalency assertion using the ExcludeNestedObjects method.

Bug fixes and minor improvements

  • We added a non-generic overload of BeOfType. (#37)
  • Rory Primrose ensured that the ShouldThrow and ShouldNotThrow methods now properly support nested aggregate exceptions. (#19)
  • Although we didn’t actually change anything, the authors of NSpec have confirmed FA works with their framework well. 
  • We fixed an intermittent cyclic reference error that sometimes occurred when asserting the equivalency of a complex object graph using the ShouldBeEquivalentTo method.
  • Adam Ralph fixed a NullReferenceException in the DefaultValueFormatter when a ToString override returns null.
  • Nullable properties were never properly passed into any custom assertions during an assertion of the structural equality (#33).
  • Gregor Stamac also fixed an object equivalency assertion error when working with nullable DateTime objects.
  • xelement.Should().Be() / NotBe() threw an exception when the expected object was null (#36)
  • Mark Lam improved the behavior of the collection assertions when working with collections of strings. FA will no longer try to interpret a string as a collection of characters.
  • When using ShouldAllBeEquivalentTo to compare two collections with the same number of elements but one contains duplicates (so some items are missing) the assertion wouldn’t fail. Gregor Stamac fixed this for us as well.
  • The collection assertion NotBeEquivalentTo incorrectly interpreted two intersecting collections of the same length as ‘equivalent’. (#52)
  • Improved the resilience of the DateTime and Type assertions against null values.

Breaking changes

  • The old property comparison API (e.g. object.ShouldHave().AllProperties().EqualTo(other)) has been marked as [Obsolete] and will be removed in the next major version. Please use the newer object equivalency API.
  • Although it may not be a widely used feature, as of version 2.2, Fluent Assertions will not automatically search for custom value formatters anymore. This scanning proved to incur a significant performance hit. Now you need to explicitly enable that using the <appSetting> with key valueFormatters. Valid values include Disabled (the default), Scan and Specific. The 2nd option will scan all assemblies in the AppDomain as version 2.1 did by default. The last option also requires you to set the valueFormattersAssembly setting key with the (partial) name of an assembly FA should scan. Since Silverlight and Windows Phone do not support an app.config file, you’ll need to configure those settings through the ValueFormatterDetectionMode and ValueFormatterAssembly properties of the static Configuration.Current object.

Fluent Assertions 2.1

24 August 2013 What are the major features

  • Added support for Windows Phone 8 test projects, both using the Visual Studio 2010 test harnass, as well as the new MSTest based framework introduced in Visual Studio 2012 Update 2 (#12470)
  • Added support for AggregateExceptions in .NET 4.0 or newer so that aggregated exceptions are treated the same way as normal exceptions. This also allows you to use Should(Not)Throw() to assert a specific exception has occurred (or not), even if it is wrapped in an AggregateException (#12482).
  • ShouldBeEquivalent() will attempt to report all differences rather than just the first one. It also supports nested dictionaries (#12472).
  • By default the order of items in (nested) collections is ignored while asserting the equivalency of two object graphs. You can override this using the WithStrictOrder()/WithStrictOrderFor() options, with or without a specific path or predicate. Notice that for performance reasons, collections of bytes are still compared in exact order (#12484).

What other improvements are new

  • Added support for asserting a method is decorated with a certain attribute (by Nathan Roe)
  • Added BeWritable() to the property info assertions .
  • XName support for all XML-related assertiosn (#12453 by Igor Khavkin)
  • Added Should().BeApproximately() for decimal values.
  • Added support for ShouldNotThrow() on Func<Task> so that you can verify that asynchronous functions threw a task (by Igor Khavkin)
  • Ensured that all reference type assertions inherit from ReferenceTypeAssertions so that they all share some basic methods like (Not)BeNull.
  • Added support for string.Should().NotStartWith() and string.Should().NotEndWith(). Also added the case-insensitive versions of them. (#12441)
  • Allowed adding, removing and/or reordering the steps the EquivalencyValidator executes while comparing two object graphs for structural equality.
  • By default, the exception message assertions are based on wildcards and case-insensitive. The ComparisonMode enum has been marked obsolete.

Bug fixes

  • Added catching of FileLoadExceptions so AttributeBasedFormatter will not crash on certain circumstances.
  • Made test framework detection based on assembly scanning case insensitive (#12483)
  • Fixed a type-mismatch error when two nullable properties were compared using an AssertionRule.
  • The method collection.ShouldBeEquivalent() ignored duplicates in the expectation.
  • Applied a small improvement by Groostav to collection.HaveCount() because it was counting collections through LINQ Count() even though it has a normal Count property (#12469).
  • Comparing a null collection with another null collection will now succeed (#12490)
  • When a type was generic, FA wouldn’t display its properties in assertion failures (#12492)
  • On Mono, the AttributeBasedFormatter sometimes throws a NullReferenceException, but this has been fixed by Frank Ebersoll (#12487).
  • During a structural equality check, FA would incorrectly decide to include protected properties in the comparison. This has been fixed now (#12486).
  • FA chocked on properties overriden using the new keyword. Now it just tries to be smart about it and select the one which type matches the subject (#12481).
  • When a floating point value representing NaN was compared with another approximate value, it didn’t throw (#12479).
  • Improved the details of any unexpected exceptions during the ShouldThrow() and ShouldNotThrow() methods (#12473).
  • Collection.ShouldBeInAscendingOrder() wasn’t reporting the correct index if an item appeared out-of-order (#12468).

Breaking changes

  • Renamed the Execute.Verification property to Execute.Assertion and introduced an internal AssertionScope.