У меня есть модульный тест, в котором я использую маппер из Model в ViewModel и ViewModel обратно в Model the Update, но на самом деле я ничего не изменил, просто тестирую, что обновление работает.
[TestMethod]
public void UpdateEntry()
{
//Map Model to ViewModel
Mapper.CreateMap<GlobalExport, GlobalExportViewModel>();
Mapper.CreateMap<FileNameSetup, FileNameSetupViewModel>();
Mapper.CreateMap<FileNameVariable, FileNameVariableViewModel>();
Mapper.CreateMap<EmailSetup, EmailSetupViewModel>();
Mapper.CreateMap<SelectedSection, SelectedSectionViewModel>();
Mapper.CreateMap<AvailableSection, AvailableSectionViewModel>();
Mapper.CreateMap<AvailableColumn, AvailableColumnViewModel>();
Mapper.CreateMap<Policy, PolicyViewModel>();
Mapper.CreateMap<SelectedColumn, SelectedColumnViewModel>();
Mapper.CreateMap<SelectedEmployeeSeaServiceType, SelectedEmployeeSeaServiceTypeViewModel>();
Mapper.CreateMap<SelectedEmployeeStatus, SelectedEmployeeStatusViewModel>();
Mapper.CreateMap<EmployeeStatus, EmployeeStatusViewModel>();
Mapper.CreateMap<EmployeeSubStatus, EmployeeSubStatusViewModel>();
Mapper.CreateMap<SelectedEmployeeSubStatus, SelectedEmployeeSubStatusViewModel>();
Mapper.CreateMap<SelectedSeaServiceType, SelectedSeaServiceTypeViewModel>();
GlobalExport globalExport = _service.GetGlobalExportById(1);
GlobalExportViewModel globalExportViewModel = Mapper.Map<GlobalExport, GlobalExportViewModel>(globalExport);
//Map ViewModel to Model
Mapper.CreateMap<GlobalExportViewModel, GlobalExport>();
Mapper.CreateMap<FileNameSetupViewModel, FileNameSetup>();
Mapper.CreateMap<FileNameVariableViewModel, FileNameVariable>();
Mapper.CreateMap<EmailSetupViewModel, EmailSetup>();
Mapper.CreateMap<SelectedSectionViewModel, SelectedSection>();
Mapper.CreateMap<AvailableSectionViewModel, AvailableSection>();
Mapper.CreateMap<AvailableColumnViewModel, AvailableColumn>();
Mapper.CreateMap<PolicyViewModel, Policy>();
Mapper.CreateMap<SelectedColumnViewModel, SelectedColumn>();
Mapper.CreateMap<SelectedEmployeeSeaServiceTypeViewModel, SelectedEmployeeSeaServiceType>();
Mapper.CreateMap<SelectedEmployeeStatusViewModel, SelectedEmployeeStatus>();
Mapper.CreateMap<EmployeeStatusViewModel, EmployeeStatus>();
Mapper.CreateMap<EmployeeSubStatusViewModel, EmployeeSubStatus>();
Mapper.CreateMap<SelectedEmployeeSubStatusViewModel, SelectedEmployeeSubStatus>();
Mapper.CreateMap<SelectedSeaServiceTypeViewModel, SelectedSeaServiceType>();
GlobalExport newGlobalExport = Mapper.Map<GlobalExportViewModel, GlobalExport>(globalExportViewModel);
_service.UpdateGlobalExport(newGlobalExport);
}
Я получаю эту ошибку:
Может кто-нибудь высказать свое мнение или лучше решение: P Большое спасибо!