Reputation: 1
I tried to create for mapper moq object but it is not working can anyone help on the how to access the mapping solution while run the test case in service method. I tried below code
private Mock<IMapper> _mapper = new Mock<IMapper>();
I pass the service dependency injection
_abcService = new AbcService(_mapper.Object);
System.NullReferenceException: 'Object reference not set to an instance of an object.'
getting this error
Upvotes: 0
Views: 255
Reputation: 414
As Jimmy Bogard stated in his AutoMapper Usage Guide don't mock AutoMapper because it doesn't add any value. Just pass real instance to your service and mock elsewhere ex. the data layer. This means that you should not have any business logic in you configuration profiles.
You can also assert that your configuration profiles are correct. See this. May be relevant to that question.
Upvotes: 1