One solution would be to stop passing
null values around everywhere. That would require changes much wider than the scope of this method though.
The biggest thing that can be won here is the
?. operator. If the left hand side is
null, the result will be
null as well:
product?.productTests?.Select(x => _productService.Map(x))?.ToList();
will remove the need for the first two null checks.
null instead of an empty list is... questionable, but if you must return
null you can check afterwards:
public List<TestDTO> Map(product product)
var list = product?.productTests?.Select(x => _productService.Map(x))?.ToList();
if (list?.Count == 0) return null;