Skip to content

Commit

Permalink
fix: issue #339
Browse files Browse the repository at this point in the history
  • Loading branch information
dupdob committed Jun 9, 2023
1 parent 1a4a3fe commit 6cab2bb
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 108 deletions.
8 changes: 4 additions & 4 deletions code/.build/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyInformationalVersion("3.0.0.0-alpha")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyVersion("3.0.1.0")]
[assembly: AssemblyInformationalVersion("3.0.1.0")]

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
Expand All @@ -35,7 +35,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Thomas PIERRAIN (thomas@pierrain.net), Cyrille DUPUYDAUBY (@_dupdob_), Rui CARVALHO, Marc-Antoine LATOUR and Co")]
[assembly: AssemblyProduct("NFluent")]
[assembly: AssemblyCopyright("Copyright © 2013-2020. Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0).")]
[assembly: AssemblyCopyright("Copyright © 2013-2023. Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0).")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
98 changes: 98 additions & 0 deletions code/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,101 @@
# V 3.0.0
## 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.

## GitHub Issues
* #325, #327, #330, #332

### Obsolete
#### Marked as obsolet
* `ThatAsyncCode`: you can now use `ThatCode` even for async methods.

Here is the list of methods, classes and other obsolete stuff that have been removed in this version as well
as workaround advices.
* Drop support for Net 2.0 and 3.0: keep using NFluent V2.x versions if you support for these.
* `Check.ThatEnum`has been removed. You must use `Check.That` instead.
* `ILambdaCheck`: the definition was kept to prevent breaking build, but it was no longer used. If this is a
problem for you, open an issue
* `IsPositive` (available for numbers): please use `IsStrictlyPositive` instead.
* `IsNegative` (available for numbers): please use `IsStrictlyNegative` instead.
* `IsLessThan` (available for numbers): please use `IsStrictlyNegative` instead.
* `IsGreaterThan` (available for numbers): please use `IsStrictlyGreaterThan` instead.
* `IsSameReferenceThan`: please use `IsSameReferenceAs` instead.
* `HasFieldsEqualToThose`: please use `HasFieldsWithSameValues` instead.
* `HasFieldsNotEqualToThose`: please use `HasNotFieldsWithSameValues` instead.
* `IsAFaillingCheckWithMessage`: please use `IsAFailingCheckWithMessage` instead.
* `IsAFaillingCheck`: please use `IsAFailingCheck` instead.
* `Properties` (available for enumeration): please use `Extracting` instead.
* `Checker.BuildLinkWhich` (used for custom extension): please use `ExtensibilityHelper.BuildCheckLinkWhich` instead.
* `Checker.ExecuteCheckAndProvideSubItem` (used for custom extension): please 'ExtensibilityHelper' static class methods instead.

# V 2.8.0
## Breaking changes
* Removed typed overload for IsEqualTo. This may degrade autocompletion somewhat;
* Equality comparison logic has been slightly revised to take failing `Equals` result when the expected type provides a specific implementation (only success was used so far).

## New check
* Is : replaces the typed overload for IsEqualTo

## GitHub Issue
* #335


# V 2.7.2
## Fixes
* HasFieldWithSameValues resulted in false positive when string fields had the same value.
* IsZero failed for very small double (<1E-28) in previous versions.
* IsEquivalentTo was not permissive enougth for dictionaries.

## GitHub Issues
* #331, #333#

# V 2.7.1
# Fixes
* HasFieldsWithSameValues failed to properly compare when the expected value contained duplicate string.
More generally, instances where only checked once for equality; any subsequent check was assumed to be succesful.
This could lead to false positive (i.e. checks succeeded when it should have failed).
This regression was introduced by V 2.2.0 in 02/2018. Sorry about that.

# GitHub Issues
* #331

## V 2.7.1
### Fixes
* HasFieldsWithSameValues failed to properly compare when the expected value contained duplicate string.
Expand Down
61 changes: 30 additions & 31 deletions code/NFluent.sln
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{DEE62612-3A5D-4D3F-9DDD-84B869E9184F}"
ProjectSection(SolutionItems) = preProject
..\docs\ArchitectureDecisionRecord.md = ..\docs\ArchitectureDecisionRecord.md
..\docs\Backlog.md = ..\docs\Backlog.md
Changelog.md = Changelog.md
..\docs\DevDoD.md = ..\docs\DevDoD.md
..\docs\ForNCrunchUsers.md = ..\docs\ForNCrunchUsers.md
Expand Down Expand Up @@ -133,36 +132,6 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NFluent.Analyzer.Test", "src\Analyzer\NFluent.Analyzer\NFluent.Analyzer.Test\NFluent.Analyzer.Test.csproj", "{4D1E60F2-64ED-452F-9A4F-5A3C8EEFD05A}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
tests\NFluent.Tests.Generated\NFluent.Tests.Generated.projitems*{0014c223-a481-4b87-a480-3d4792a9b276}*SharedItemsImports = 4
tests\NFluent.Tests\NFluent.Tests.projitems*{0014c223-a481-4b87-a480-3d4792a9b276}*SharedItemsImports = 4
tests\NFluent.Tests.ReportedIssues\NFluent.Tests.ReportedIssues.projitems*{0147471a-18d2-4714-8cda-37da471e0e45}*SharedItemsImports = 13
tests\NFluent.Tests\NFluent.Tests.projitems*{0425a660-ca7d-43f6-93ab-f72c95d506e3}*SharedItemsImports = 13
tests\NFluent.Tests.Extensions\NFluent.Tests.Extensions.projitems*{2b7f0e07-9b42-4bd2-8e30-f90fd78faf1f}*SharedItemsImports = 13
tests\NFluent.Tests.Extensions\NFluent.Tests.Extensions.projitems*{308a72a3-462b-4c4e-abae-9d9d49d251e7}*SharedItemsImports = 4
src\NFluent.Generated\NFluent.Generated.projitems*{37fdae31-560d-40b8-8fa7-7def8a53b370}*SharedItemsImports = 13
src\NFluent.Generated\NFluent.Generated.projitems*{3a474510-f384-41ce-9270-539b1e51da7e}*SharedItemsImports = 4
src\NFluent\NFluent.projitems*{3a474510-f384-41ce-9270-539b1e51da7e}*SharedItemsImports = 4
tests\NFluent.Tests.Meta\NFluent.Tests.Meta.projitems*{61d00587-a426-41de-970b-8cdf5c7a0e67}*SharedItemsImports = 13
tests\NFluent.Tests.Extensions\NFluent.Tests.Extensions.projitems*{6954e791-41c2-4d1f-b6e6-ba77c2784311}*SharedItemsImports = 5
tests\NFluent.Tests.Generated\NFluent.Tests.Generated.projitems*{6b88c45a-d45e-40fb-8635-d0e0ef0454e9}*SharedItemsImports = 4
tests\NFluent.Tests\NFluent.Tests.projitems*{6b88c45a-d45e-40fb-8635-d0e0ef0454e9}*SharedItemsImports = 4
tests\NFluent.Tests.Internals\NFluent.Tests.Internals.projitems*{8f0252a6-1bb6-4bf6-a852-33eafb6852ca}*SharedItemsImports = 5
tests\NFluent.Tests.Internals\NFluent.Tests.Internals.projitems*{95799318-9a09-46c8-ae53-2546f053ef40}*SharedItemsImports = 4
tests\NFluent.Tests.Internals\NFluent.Tests.Internals.projitems*{9e500148-4f6c-424a-aa09-801db1749677}*SharedItemsImports = 4
tests\NFluent.Tests.Internals\NFluent.Tests.Internals.projitems*{ab38506b-6cd4-47ed-a085-a77e8a5be26c}*SharedItemsImports = 13
tests\NFluent.Tests.Extensions\NFluent.Tests.Extensions.projitems*{ac520fdb-8125-46f3-85f3-d4962c53c136}*SharedItemsImports = 4
tests\NFluent.Tests.Meta\NFluent.Tests.Meta.projitems*{c2eec8dd-f390-4ecb-a169-25930896e1c1}*SharedItemsImports = 4
src\NFluent.Generated\NFluent.Generated.projitems*{c90111a0-3ab2-40ed-b665-c0ddb8deb26e}*SharedItemsImports = 5
src\NFluent\NFluent.projitems*{c90111a0-3ab2-40ed-b665-c0ddb8deb26e}*SharedItemsImports = 5
src\NFluent.Generated\NFluent.Generated.projitems*{cf1d857f-658f-4e1f-8487-cd751f189e6a}*SharedItemsImports = 4
src\NFluent\NFluent.projitems*{cf1d857f-658f-4e1f-8487-cd751f189e6a}*SharedItemsImports = 4
src\NFluent\NFluent.projitems*{dbfa1137-b129-496a-9201-149f5178747e}*SharedItemsImports = 13
tests\NFluent.Tests.Generated\NFluent.Tests.Generated.projitems*{e298f1af-a6a7-497c-9a2d-ac15584e1ac1}*SharedItemsImports = 13
tests\NFluent.Tests.ReportedIssues\NFluent.Tests.ReportedIssues.projitems*{f4872eaa-bf75-47ec-a8ef-7791a0e89b50}*SharedItemsImports = 5
tests\NFluent.Tests.Generated\NFluent.Tests.Generated.projitems*{fe288842-65f6-47dc-952a-413077247511}*SharedItemsImports = 5
tests\NFluent.Tests\NFluent.Tests.projitems*{fe288842-65f6-47dc-952a-413077247511}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -320,4 +289,34 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A9A6ED20-537A-4D69-82C7-53AF50CEAEE8}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
tests\NFluent.Tests.Generated\NFluent.Tests.Generated.projitems*{0014c223-a481-4b87-a480-3d4792a9b276}*SharedItemsImports = 4
tests\NFluent.Tests\NFluent.Tests.projitems*{0014c223-a481-4b87-a480-3d4792a9b276}*SharedItemsImports = 4
tests\NFluent.Tests.ReportedIssues\NFluent.Tests.ReportedIssues.projitems*{0147471a-18d2-4714-8cda-37da471e0e45}*SharedItemsImports = 13
tests\NFluent.Tests\NFluent.Tests.projitems*{0425a660-ca7d-43f6-93ab-f72c95d506e3}*SharedItemsImports = 13
tests\NFluent.Tests.Extensions\NFluent.Tests.Extensions.projitems*{2b7f0e07-9b42-4bd2-8e30-f90fd78faf1f}*SharedItemsImports = 13
tests\NFluent.Tests.Extensions\NFluent.Tests.Extensions.projitems*{308a72a3-462b-4c4e-abae-9d9d49d251e7}*SharedItemsImports = 4
src\NFluent.Generated\NFluent.Generated.projitems*{37fdae31-560d-40b8-8fa7-7def8a53b370}*SharedItemsImports = 13
src\NFluent.Generated\NFluent.Generated.projitems*{3a474510-f384-41ce-9270-539b1e51da7e}*SharedItemsImports = 4
src\NFluent\NFluent.projitems*{3a474510-f384-41ce-9270-539b1e51da7e}*SharedItemsImports = 4
tests\NFluent.Tests.Meta\NFluent.Tests.Meta.projitems*{61d00587-a426-41de-970b-8cdf5c7a0e67}*SharedItemsImports = 13
tests\NFluent.Tests.Extensions\NFluent.Tests.Extensions.projitems*{6954e791-41c2-4d1f-b6e6-ba77c2784311}*SharedItemsImports = 5
tests\NFluent.Tests.Generated\NFluent.Tests.Generated.projitems*{6b88c45a-d45e-40fb-8635-d0e0ef0454e9}*SharedItemsImports = 4
tests\NFluent.Tests\NFluent.Tests.projitems*{6b88c45a-d45e-40fb-8635-d0e0ef0454e9}*SharedItemsImports = 4
tests\NFluent.Tests.Internals\NFluent.Tests.Internals.projitems*{8f0252a6-1bb6-4bf6-a852-33eafb6852ca}*SharedItemsImports = 5
tests\NFluent.Tests.Internals\NFluent.Tests.Internals.projitems*{95799318-9a09-46c8-ae53-2546f053ef40}*SharedItemsImports = 4
tests\NFluent.Tests.Internals\NFluent.Tests.Internals.projitems*{9e500148-4f6c-424a-aa09-801db1749677}*SharedItemsImports = 4
tests\NFluent.Tests.Internals\NFluent.Tests.Internals.projitems*{ab38506b-6cd4-47ed-a085-a77e8a5be26c}*SharedItemsImports = 13
tests\NFluent.Tests.Extensions\NFluent.Tests.Extensions.projitems*{ac520fdb-8125-46f3-85f3-d4962c53c136}*SharedItemsImports = 4
tests\NFluent.Tests.Meta\NFluent.Tests.Meta.projitems*{c2eec8dd-f390-4ecb-a169-25930896e1c1}*SharedItemsImports = 4
src\NFluent.Generated\NFluent.Generated.projitems*{c90111a0-3ab2-40ed-b665-c0ddb8deb26e}*SharedItemsImports = 5
src\NFluent\NFluent.projitems*{c90111a0-3ab2-40ed-b665-c0ddb8deb26e}*SharedItemsImports = 5
src\NFluent.Generated\NFluent.Generated.projitems*{cf1d857f-658f-4e1f-8487-cd751f189e6a}*SharedItemsImports = 4
src\NFluent\NFluent.projitems*{cf1d857f-658f-4e1f-8487-cd751f189e6a}*SharedItemsImports = 4
src\NFluent\NFluent.projitems*{dbfa1137-b129-496a-9201-149f5178747e}*SharedItemsImports = 13
tests\NFluent.Tests.Generated\NFluent.Tests.Generated.projitems*{e298f1af-a6a7-497c-9a2d-ac15584e1ac1}*SharedItemsImports = 13
tests\NFluent.Tests.ReportedIssues\NFluent.Tests.ReportedIssues.projitems*{f4872eaa-bf75-47ec-a8ef-7791a0e89b50}*SharedItemsImports = 5
tests\NFluent.Tests.Generated\NFluent.Tests.Generated.projitems*{fe288842-65f6-47dc-952a-413077247511}*SharedItemsImports = 5
tests\NFluent.Tests\NFluent.Tests.projitems*{fe288842-65f6-47dc-952a-413077247511}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
36 changes: 6 additions & 30 deletions code/ReleaseNoteContentToBeInsertedWithinNuspecFile.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#V 3.0.0.1
## Fix
* Fix `Check.ThatCode` not awaiting `Task` returning lambdas in V3.0.0. Note that `Task<T>` returning lambdas do work in V3.0.0
* an InvalidOperation is thrown when using `Check.ThatCode` on an async void method/lambda (as those cannot be awaited)


# V 3.0.0
## 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:
Expand Down Expand Up @@ -65,33 +71,3 @@ problem for you, open an issue
* `Checker.BuildLinkWhich` (used for custom extension): please use `ExtensibilityHelper.BuildCheckLinkWhich` instead.
* `Checker.ExecuteCheckAndProvideSubItem` (used for custom extension): please 'ExtensibilityHelper' static class methods instead.

# V 2.8.0
## Breaking changes
* Removed typed overload for IsEqualTo. This may degrade autocompletion somewhat;
* Equality comparison logic has been slightly revised to take failing `Equals` result when the expected type provides a specific implementation (only success was used so far).

## New check
* Is : replaces the typed overload for IsEqualTo

## GitHub Issue
* #335


# V 2.7.2
## Fixes
* HasFieldWithSameValues resulted in false positive when string fields had the same value.
* IsZero failed for very small double (<1E-28) in previous versions.
* IsEquivalentTo was not permissive enougth for dictionaries.

## GitHub Issues
* #331, #333#

# V 2.7.1
# Fixes
* HasFieldsWithSameValues failed to properly compare when the expected value contained duplicate string.
More generally, instances where only checked once for equality; any subsequent check was assumed to be succesful.
This could lead to false positive (i.e. checks succeeded when it should have failed).
This regression was introduced by V 2.2.0 in 02/2018. Sorry about that.

# GitHub Issues
* #331
20 changes: 17 additions & 3 deletions code/src/NFluent/Extensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
namespace NFluent.Extensions
{
using System;

#if !DOTNET_35
using System.Threading.Tasks;
#endif
internal static class ObjectExtensions
{

#if !NETSTANDARD1_3 && !DOTNET_45
#if !DOTNET_45
/// <summary>
/// Stub implementation for GetTypeInfo() for Net Framework.
/// </summary>
Expand Down Expand Up @@ -59,5 +60,18 @@ public static bool IsAnEnumeration<T>(this T instance, bool evenWellKnown)
{
return instance!= null && instance.GetTypeWithoutThrowingException().IsAnEnumeration(evenWellKnown);
}

public static bool IsAwaitable<T>(this T instance, out Action waiter)
{
#if !DOTNET_35
if (instance is Task ta && ta.Status != TaskStatus.Created)
{
waiter = () => ta.Wait();
return true;
}
#endif
waiter = () =>{};
return false;
}
}
}
Loading

0 comments on commit 6cab2bb

Please sign in to comment.