我有以下控制器动作
public ActionResult EditFocus(int id)
{
var Focus = focusService.GetFocus(id);
Mapper.CreateMap<Focus, FocusFormModel>()
FocusFormModel editFocus = Mapper.Map<Focus, FocusFormModel>(Focus);
if (Focus == null)
{
return HttpNotFound();
}
return View("EditFocus", editFocus);
我正在使用 Nunit 进行测试。测试是
[Test]
public void Edit_Get_ReturnsView()
{
FocusFormModel group = new FocusFormModel() { FocusId = 1, FocusName = "Test" };
Mapper.CreateMap<Focus, FocusFormModel>().ForAllMembers(opt => opt.Ignore());
Focus focusViewModel = Mapper.Map<Focus, FocusFormModel>(group);
Mapper.AssertConfigurationIsValid();
focusRepository.Setup(x => x.GetById(1)).Returns(focusViewModel);
FocusController controller = new GroupController(focusService);
ViewResult actual = controller.EditFocus(1) as ViewResult;
Assert.IsNotNull(actual, "View Result is null");
}
但测试失败在 NUnit GUI 中出现以下错误:
Missing Mapping type Configuration& Unsupported Mapping