Vinod Kumar

Vinod Kumar

  • NA
  • 2
  • 1.4k

AutoMapper Version Used : 3.3.10

May 11 2016 5:18 AM

[TestClass] public class AppControllerTests 
{ 
private IMappingEngine _mappingEngine = null; 
private ConfigurationStore _configurationStore = null; 
[TestInitialize] 
public void SetUp() 
{      
 _configurationStore = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers);  
      _configurationStore.AddProfile(new AutoMapperProfile.AppProfile());        
 _mappingEngine = new MappingEngine(_configurationStore);
 } 
[TestMethod] 
public void GetAppByAccountID() 
{ // Error line  var mappingResult = _mappingEngine.Map<Category>(categoryList).AsQueryable();
 }
 } 
 
public class AppProfile : Profile 
{ 
protected override void Configure() 
{ 
AutoMapperMappingConfigurations();
 } 
public void AutoMapperMappingConfigurations() 
{ Mapper.CreateMap<DomainModels.Category, Category>().ReverseMap(); 

}
 }

Exception:

An exception of type 'AutoMapper.AutoMapperMappingException' occurred in AutoMapper.dll but was not handled in user code.

Suspect the

_configurationStore.AddProfile(new OOS.PresentationModelService.AutoMapperProfile.AppProfile());

is not able to create an istance of AppProfile if i write the manual mapping it's working as expected.

_configurationStore.CreateMap<Category, Category>().ReverseMap();



Answers (1)