Code
[TestClass] public class AppControllerTestsCode
{Code
private IMappingEngine _mappingEngine = null;Code
private ConfigurationStore _configurationStore = null;Code
[TestInitialize]Code
public void SetUp()Code
{Code
_configurationStore = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers);Code
_configurationStore.AddProfile(new AutoMapperProfile.AppProfile());Code
_mappingEngine = new MappingEngine(_configurationStore);Code
}Code
[TestMethod]Code
public void GetAppByAccountID()Code
{ // Error line var mappingResult = _mappingEngine.MapCategory>(categoryList).AsQueryable();Code
}Code
}Code
Code
public class AppProfile : ProfileCode
{Code
protected override void Configure()Code
{Code
AutoMapperMappingConfigurations();Code
}Code
public void AutoMapperMappingConfigurations()Code
{ Mapper.CreateMapDomainModels.Category, Category>().ReverseMap();Code
Code
}Code
}Code
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());C#
is not able to create an istance of AppProfile if i write the manual mapping it's working as expected.
_configurationStore.CreateMapCategory, Category>().ReverseMap();
Ritesh SinghRank #2,164 · 658 reputationPosted Jul 26, 2016, 4:19 AM EDT
Mapperclass) :