Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Unit tests #131

Closed
mrpmorris opened this issue Jun 28, 2020 · 1 comment
Closed

Unit tests #131

mrpmorris opened this issue Jun 28, 2020 · 1 comment

Comments

@mrpmorris
Copy link

I used to write my mappings manually until I started to use AutoMapper.

Preventing me from having to write mapper code wasn't what saved me lots of time though, it was the fact that I could validate that no members have been missed.

Do you have something to cater for ensuring the mappers are up to date with the target and source classes?

@cezarypiatek
Copy link
Owner

Hi,

For validation in design time, if all members of the target object are assigned, you can use my another extension which is described here Immutable types in C# with Roslyn - this can be solved with [InitRequire] attribute or /*FullInitRequired*/ marker.

For runtime validation - you can use tools like https://github.com/approvals/ApprovalTests.Net to create easy to maintain unit tests without the need to hardcode the assertions for all target members.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants