Hey guys! I am using AutoMapper to map my service objects to DTOs, but i was wondering if I am doing it clean.
[HttpPost]
public IActionResult Get()
{
var map = _mapService.GetMap();
var result = _mapper.Map<MapDto>(map);
return Ok(result);
}
How do I make sure that this works? I have created some tests for the controller but they don't feel quite right...
Test startup method:
public MapControllerTests()
{
mapService = new Mock<IMapService>();
mapper = new Mock<IMapper>();
var serviceResponse = new Map { Points = [new Point()] };
mapService.Setup(m => m.GetMap()).Returns(serviceResponse);
mapper.Setup(m => m.Map<MapDto>(serviceResponse)).Returns(new MapDto { Points = [] }); // <-- Feels like too much logic in test
mapController = new MapController(mapper.Object, mapService.Object);
}