https://github.com/jamesfoster/deepequal
An extensible deep comparison for .NET
https://github.com/jamesfoster/deepequal
c-sharp compare deep-equal deep-equals equality testing
Last synced: 7 months ago
JSON representation
An extensible deep comparison for .NET
- Host: GitHub
- URL: https://github.com/jamesfoster/deepequal
- Owner: jamesfoster
- License: mit
- Created: 2013-05-18T13:23:35.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-07-14T11:49:58.000Z (over 1 year ago)
- Last Synced: 2025-06-02T01:42:57.949Z (8 months ago)
- Topics: c-sharp, compare, deep-equal, deep-equals, equality, testing
- Language: C#
- Size: 570 KB
- Stars: 232
- Watchers: 11
- Forks: 32
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
DeepEqual
=
DeepEqual is an extensible deep equality comparison library.
Installing
-
Install via NuGet (https://www.nuget.org/packages/DeepEqual/)
`Install-Package DeepEqual`
Usage
-
To test equality simply call the `IsDeepEqual` extension method.
```c#
bool result = left.IsDeepEqual(right);
```
When used inside a test you might want to call `ShouldDeepEqual` instead. This method throws an exception with a detailed description of the differences between the 2 objects.
```c#
left.ShouldDeepEqual(right);
// or
left.ShouldDeepEqual(right, comparison);
```
You can pass a custom comparison as the second argument to the `ShouldDeepEqual` method to override the default behaviour. You can also customize the behaviour inline using the `WithDeepEqual` extension method.
```c#
left.WithDeepEqual(right)
.SkipDefault()
.IgnoreLeftProperty(x => x.Id)
.Assert()
```