Skip to content

Releases: fluentassertions/fluentassertions

Fluent Assertions 3.1

06 Feb 10:35
Compare
Choose a tag to compare

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 Dec 18:32
Compare
Choose a tag to compare

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 Aug 11:38
Compare
Choose a tag to compare

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.