A tool for testing (asserting) mapping of properties by comparing one object to another.
$ dotnet add package Udir.PropertyMappingAsserterA utility to test mapping of properties from one object to another.
var asserter = Udir.PropertyMappingAsserter.NUnit.PropertyMappingAsserter.Factory;
asserter.Assert(source, target)
.SetsTarget.ToSource()
.AllPublicPropertiesAreAsserted();
An exception is thrown if any of the properties in target with
corresponding properties (name and type) in source differ.
Will also throw an exception if any public properties in target
don't have any corresponding properties in source.
Alternatively, the matches can be specified:
var asserter = Udir.PropertyMappingAsserter.NUnit.PropertyMappingAsserter.Factory;
asserter.Assert(source, target)
.Sets(t => t.Number).To(s => s.Number)
.Sets(t => t.Text).To(s => s.SomePropertyinSourceWithSameType);