System.InvalidOperationException:“Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.”
Here is the code for the method that I'm developing the unit test for:
Following is the code from the mapping configuration file:
And I have initialized mapper in the
Below is the simple test method that I'm trying to run:
It works fine when I simply run the application. But when I try to run the unit test method, it shows the mentioned error message. Can anyone help me to get over this issue? Thanks! |
|||
You need to create/register the mappings for your unit tests as well as the
In the above test the mapping configuration is done in a method decorated with
|
MappingConfig.RegisterMaps();
in your unit tests? – Nkosi Aug 17 '16 at 15:25