public void Setup() { _source = new SourceModels.Employee { Id = 671378612, FirstName = "First", LastName = "Last", Email = "*****@*****.**", DateOfBirth = new System.DateTime(1980, 2, 5), YearsOfService = 3, Salary = 125478.45m, Subordinates = new System.Collections.Generic.List <SourceModels.Employee> { new SourceModels.Employee { Id = 671378612, FirstName = "Firrrrst", LastName = "Lasssst", Email = "*****@*****.**", DateOfBirth = new System.DateTime(1986, 12, 4), YearsOfService = 6, Salary = 4567.15m, } } }; var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <SourceModels.Employee, TargetModels.Employee>(); }); _mapper = configuration.CreateMapper(); }
private static TargetModels.Employee Map(SourceModels.Employee source) { if (source == null) { return(null); } return(new TargetModels.Employee { Id = source.Id, FirstName = source.FirstName, LastName = source.LastName, Email = source.Email, DateOfBirth = source.DateOfBirth, YearsOfService = source.YearsOfService, Salary = source.Salary, Subordinates = source.Subordinates?.Select(Map).ToList() }); }