Fluent Assertions 2.2

@dennisdoomen dennisdoomen released this Dec 30, 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.