Base solution for your next web application
Open Closed

Automapper Initialization Error in Unit Test Projects. #2744


User avatar
0
ajay created

Hello,

I am getting following error when working with unit tests in ABP project template.

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.

I have following in my GetList Method in ProductAppService Class.

return new ListResultDto<ProductDto>(countries.MapTo<List<ProductDto>>());

This works fine in web but throw error with Unit Tests.

Thanks.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This might be the same problem you area facing <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1386">https://github.com/aspnetboilerplate/as ... ssues/1386</a>.