New functionality
- Gregor Stamac extended the XML assertions with the methods
BeEquivalentTo
andNotBeEquivalentTo
to perform a deep comparison between two XML fragments. - Vossad01 added a
Be
overload to theNullableSimpleTimeSpanAssertions
which allowsBe
assertions against a nullableTimeSpan
(#5). - He also added
NotBeNullOrWhiteSpace
to the string assertions and marked the oldBeBlank
andNotBeBlank
as[Obsolete]
(#7). - ClockworkPenguin extended the string assertions with
MatchRegex
andNotMatchRegex
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 theEquivalencyAssertionOptions
of the object graph comparison API. (#16) - Added
NotBeTrue
andNotBeFalse
assertions for (nullable) booleans. - Added
BeCloseTo
as an assertion on aTimeSpan
, similarly to what already exists forDateTime
s. (#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
andShouldNotThrow
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 theDefaultValueFormatter
when aToString
override 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
DateTime
objects. 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
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
andType
assertions againstnull
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 keyvalueFormatters
. Valid values includeDisabled
(the default),Scan
andSpecific
. The 2nd option will scan all assemblies in theAppDomain
as version 2.1 did by default. The last option also requires you to set thevalueFormattersAssembly
setting key with the (partial) name of an assembly FA should scan. Since Silverlight and Windows Phone do not support anapp.config
file, you'll need to configure those settings through theValueFormatterDetectionMode
andValueFormatterAssembly
properties of the staticConfiguration.Current
object.