Repository navigation
Fluent Assertions 2.2
New functionality
- Gregor Stamac extended the XML assertions with the methods
BeEquivalentToandNotBeEquivalentToto perform a deep comparison between two XML fragments. - Vossad01 added a
Beoverload to theNullableSimpleTimeSpanAssertionswhich allowsBeassertions against a nullableTimeSpan(#5). - He also added
NotBeNullOrWhiteSpaceto the string assertions and marked the oldBeBlankandNotBeBlankas[Obsolete](#7). - ClockworkPenguin extended the string assertions with
MatchRegexandNotMatchRegexmethods (#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
BeBinarySerializablethat can be used to tweak the internal comparison between the original and the deserialized objects based on theEquivalencyAssertionOptionsof the object graph comparison API. (#16) - Added
NotBeTrueandNotBeFalseassertions for (nullable) booleans. - Added
BeCloseToas an assertion on aTimeSpan, similarly to what already exists forDateTimes. (#45) - Added the possibility to disable recursion during an object graph equivalency assertion using the
ExcludeNestedObjectsmethod.
Bug fixes and minor improvements
- We added a non-generic overload of
BeOfType. (#37) - Rory Primrose ensured that the
ShouldThrowandShouldNotThrowmethods 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
ShouldBeEquivalentTomethod. - Adam Ralph fixed a
NullReferenceExceptionin theDefaultValueFormatterwhen aToStringoverride returnsnull. - 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
DateTimeobjects. xelement.Should().Be()/NotBe()threw an exception when the expected object wasnull(#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
ShouldAllBeEquivalentToto 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
NotBeEquivalentToincorrectly interpreted two intersecting collections of the same length as 'equivalent'. (#52) - Improved the resilience of the
DateTimeandTypeassertions againstnullvalues.
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 keyvalueFormatters. Valid values includeDisabled(the default),ScanandSpecific. The 2nd option will scan all assemblies in theAppDomainas version 2.1 did by default. The last option also requires you to set thevalueFormattersAssemblysetting key with the (partial) name of an assembly FA should scan. Since Silverlight and Windows Phone do not support anapp.configfile, you'll need to configure those settings through theValueFormatterDetectionModeandValueFormatterAssemblyproperties of the staticConfiguration.Currentobject.