A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or
BDD-style unit test. Runs on .NET 3.5, 4.0 and 4.5 (Desktop and Windows Store), Silverlight 4 and 5 and Windows Phone 7.5 and 8. Supports the unit test frameworks NUnit, XUnit, MBUnit, Gallio and MSpec.
See the version list below for details.
Install-Package FluentAssertions -Version 2.1.0
dotnet add package FluentAssertions --version 2.1.0
<PackageReference Include="FluentAssertions" Version="2.1.0" />
paket add FluentAssertions --version 2.1.0
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.
* 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).
* Renamed the Execute.Verification property to Execute.Assertion and introduced an internal AssertionScope.
This package has no dependencies.
Showing the top 10 GitHub repositories that depend on FluentAssertions:
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
Simple REST and HTTP API Client for .NET
ML.NET is an open source and cross-platform machine learning framework for .NET.
A Terminal Emulator based on UWP and web technologies.
Orleans is a cross-platform framework for building distributed applications with .NET
OpenID Connect and OAuth 2.0 Framework for ASP.NET Core
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
Smart PVR for newsgroup and bittorrent users.
LiteDB - A .NET NoSQL Document Store in a single data file - https://www.litedb.org
Git Extensions is a standalone UI tool for managing git repositories. It also integrates with Windows Explorer and Microsoft Visual Studio (2015/2017/2019).
Read more about the GitHub Usage information on our documentation.