EAXUnitHelpers.Comparison 6.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EAXUnitHelpers.Comparison --version 6.0.0                
NuGet\Install-Package EAXUnitHelpers.Comparison -Version 6.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EAXUnitHelpers.Comparison" Version="6.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EAXUnitHelpers.Comparison --version 6.0.0                
#r "nuget: EAXUnitHelpers.Comparison, 6.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EAXUnitHelpers.Comparison as a Cake Addin
#addin nuget:?package=EAXUnitHelpers.Comparison&version=6.0.0

// Install EAXUnitHelpers.Comparison as a Cake Tool
#tool nuget:?package=EAXUnitHelpers.Comparison&version=6.0.0                

EAXUnitHelpers.Comparison

This package contains custom comparators for objects and enumerables. The following uses are supported:

  • Assert.Equal(expected, actual, new CustomObjectComparer<MySpecialObject>())
  • Assert.Equal(expected, actual, new CustomEnumerableComparer<MySpecialObject>())
  • Assert.Equal(expected, actual, new CustomObjectComparer<MySpecialObject>(true))
  • Assert.Equal(expected, actual, new CustomEnumerableComparer<MySpecialObject>(true))
  • Assert.Equal(expected, actual, new CustomObjectComparer<MySpecialObject>(new List<string> {"Name", "City"}))
  • Assert.Equal(expected, actual, new CustomEnumerableComparer<MySpecialObject>(new List<string> {"Name", "City"}))
  • Assert.Equal(expected, actual, new CustomObjectComparer<MySpecialObject>(true, new List<string> {"Name", "City"}))
  • Assert.Equal(expected, actual, new CustomEnumerableComparer<MySpecialObject>(true, new List<string> {"Name", "City"}))

CustomObjectComparer should be used when two objects need to be compared (which should be obvious) and CustomEnumerableComparer should be used when two enumerables (IEnumerable, List, array, etc.) should be compared (which, again, should be obvious).

Passing true to the constructor of either CustomObjectComparer or CustomEnumerableComparer will result in the comparison checking inherited properties as well.

Passing a list of properties will restrict the comparison of the objects to those properties passed. This is case sensitive so if you want to check the "Name" then you must pass "Name" and not "name".

The contents of this package are based on an answer to a question on this topic on StackOverflow, which can be found here.

To build the NuGet package, navigate to the solution directory and run: dotnet pack ./src/EAXUnitHelpers.Comparison/EAXUnitHelpers.Comparison.csproj -o ./ -c Release

Use NuGet.org's UI to upload the generated package.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 93 6/11/2024
6.0.0 633 10/7/2022
1.0.0 2,131 5/14/2021
0.0.2 620 6/23/2019
0.0.1 721 11/4/2018