Provides a mechanism to test deep-equality of two objects with an optional list of properties to ignore by name. Deep equality testing bypasses reference-checking of container objects and compares primitive propertyt values. Use this to test whether or not two objects essentially contain the same data. More conveniently, use the following extension methods:
More...
|
| DeepEqualityTester (object objSource, object objCompare, params string[] ignorePropertiesByName) |
| Constructs a new DeepEqualityTester for a source object and compare object with an optional params array of properties to ignore by name, all the way down.
|
bool | AreDeepEqual () |
| Calculates if the two objects provided during construction are DeepEqual according to the properties set. Will always re-calculate, so if one of the provided objects changes, this will always return the current value.
|
void | AddCustomComparer< T > (IEqualityComparer< T > comparer) |
| Adds a custom comparer for the type T.
|
void | AddCustomComparer (object comparer) |
| Adds a custom comparer to use for the specified type. Custom comparers must implement IComparer<T> where T becomes the type selection to use for when the comparer is invoked.
|
|
bool | RecordErrors [get, set] |
| Toggle whether or not to record equality errors.
|
bool | FailOnMissingProperties [get, set] |
| Toggle whether or not equality testing fails when properties found on the first object are not found on the corresponding other object.
|
bool | OnlyTestIntersectingProperties [get, set] |
| Toggle whether or not to only test properties found on both objects.
|
IEnumerable< string > | Errors [get] |
| Provides a list of errors for diagnosing inequality, if RecordErrors has been set to true.
|
bool | IncludeFields [get, set] |
| Flag: include fields in deep equality testing (false by default)
|
bool | OnlyCompareShape [get, set] |
| Toggle only testing the shape of the objects provided.
|
bool | VerbosePropertyMismatchErrors = true [get, set] |
| Include full object dumps when storing errors about property mismatches.
|
EnumComparisonStrategies | EnumComparisonStrategy = EnumComparisonStrategies.ByName [get, set] |
| When comparing enum values, forget their type and only compare their integer values.
|
Provides a mechanism to test deep-equality of two objects with an optional list of properties to ignore by name. Deep equality testing bypasses reference-checking of container objects and compares primitive propertyt values. Use this to test whether or not two objects essentially contain the same data. More conveniently, use the following extension methods:
- DeepEquals -> performs default deep equality testing
- DeepSubEquals -> tests if one object matches another, for all the properties that the first has in common with the second
- DeepIntersectionEquals -> tests deep equality only on properties which can be matched by name and type
◆ EnumComparisonStrategies
Describes available methods for comparing enum values.
Enumerator |
---|
ByName | Compare enum values by name (default)
|
ByObjectEquals | Compare enum values by object equality (.Equals())
|
ByIntegerValue | Compare enum values by integer value.
|
◆ DeepEqualityTester()
PeanutButter.Utils.DeepEqualityTester.DeepEqualityTester |
( |
object | objSource, |
|
|
object | objCompare, |
|
|
params string[] | ignorePropertiesByName ) |
Constructs a new DeepEqualityTester for a source object and compare object with an optional params array of properties to ignore by name, all the way down.
- Parameters
-
objSource | Source / master object |
objCompare | Object to compare with |
ignorePropertiesByName | Params array of properties to ignore by name |
◆ AddCustomComparer()
void PeanutButter.Utils.DeepEqualityTester.AddCustomComparer |
( |
object | comparer | ) |
|
Adds a custom comparer to use for the specified type. Custom comparers must implement IComparer<T> where T becomes the type selection to use for when the comparer is invoked.
- Parameters
-
◆ AddCustomComparer< T >()
Adds a custom comparer for the type T.
- Parameters
-
- Template Parameters
-
◆ AreDeepEqual()
bool PeanutButter.Utils.DeepEqualityTester.AreDeepEqual |
( |
| ) |
|
Calculates if the two objects provided during construction are DeepEqual according to the properties set. Will always re-calculate, so if one of the provided objects changes, this will always return the current value.
- Returns
- True if the two objects are found to match; false otherwise.
The documentation for this class was generated from the following file:
- source/Utils/PeanutButter.Utils/DeepEqualityTester.cs