更新时间:2023-10-12 10:15:52
您在单元测试中缺少映射器的初始化。下面的代码在 CarsControllerTest
类构造函数中初始化映射器。
You are missing initialization of your mapper in your unit test. The following initializes the mapper in the CarsControllerTest
class constructor.
[TestFixture]
public class CarsControllerTest
{
public CarsControllerTest()
{
Mapper.Initialize(cfg =>
{
cfg.AddProfile<AutoMapperProfile>();
});
}
}