Skip to content

NFluent V3

Compare
Choose a tag to compare
@dupdob dupdob released this 09 Jun 09:37
· 11 commits to master since this release

Major changes

  • You can execute multiple check as a single batch and get every failures, instead of the first one. This can be achieved using:
    • Check.StartBatch: stores the result of each subsequent check(s) and notifies all the errors when the returned object is disposed. Such as
      using(Check.StartBatch()) { Check.That(sut)..... Check.That(sut).... }
      Note that any actual exception thrown during the check phase will prevent any subsequent check from behind executed (1) and may not be reported as it may be replaced by an assertion failure exception.
      This comes from C# exeption handling logic.
  • You can provide anonymous types and tuples when using IsEqualTo against any type. The check will be made against all
    sut's propertie.
  • NFluent supports Net 3.5 SP1, Net. 4.5.2 +, Net Standard 2.0+. Dropped support for Net Framework 2.0, 3.0, and 4.0, as well Net Standard<2.0.
    If you can't upgrade your framework version to a supported one, please use NFluent 2.7.1.

New Checks

  • Is: Checks if sut == expected. This is a strongly typed equivalent to IsEqualTo.
  • IsGreaterOrEqualThan: Checks if sut >= expected.
  • IsLessOrEqualThan: Checks if sut <= expected.

New feautres

  • You can provide custom comparer for any type, using Check.RegisterComparer like this Check.Register<MyType>(MyCustomComparer).
    You can also use RegisterLocalComparer to limit its usage to a declaration scope.

Breaking changes

  • Equality logic changed for IDictionary: dictionaries are considered equals if they have the same keys and
    the same values for each key. In NFluent V2, entries needed to be declared in the some order or else they were considered as different but equivalent.
  • You need to specify
  • IsAnInstanceOf<nullableType>(null) now fails (with an appropriate message). Previously, it did succeed. But,
    as captured in issue #68, this behavior was triggered by a bug and kept due to a poor error message when fixed.
  • The IStructCheck<T> interface has been removed as well as associated extensibility helper. Those were dedicated
    to value types, you can migrate your existing extensions to the ICheck<T> type instead. Please open an issue if
    you need help.

Fixes

  • HasFieldWithSameValues resulted in false positive when string fields had the same value.
  • IsNotEqualTo now properly preserves expected type
  • Improved rerporting of differences for enumerations and dictionaries to make them more consistent and fixed some inaccuracies.