public PagedItems<RootEntityDto> GetAll(RootEntityDto rootEntity) { RootEntity rootEntityDomain = Mapper.Map<RootEntityDto, RootEntity>(rootEntity); RootEntityDto[] ret = Mapper.Map<RootEntity[], RootEntityDto[]>(new[]{ rootEntityDomain, new RootEntity{ Id = 1, Name = "Uno", ExternalEntity = new ExternalEntity{ Id = 3, Description = "external entity 3", }, }, new RootEntity{ Id = 2, Name = "Due", ExternalEntity = new ExternalEntity{ Id = 4, Description = "external entity 4" } }, }); return new PagedItems<RootEntityDto>(ret, ret.Length); }
public void FromDtoToDomain() { var src = new RootEntityDto{ StringId = "1", Name = "root entity", ExternalEntity = new ExternalEntityRefDto{ StringId = "2", Description = "external entity", }, DetailEntities = new[]{ new DetailEntityDto{ StringId = "3", Description = "detail entity coll 1" }, new DetailEntityDto{ StringId = "4", Description = "detail entity coll 2" }, }, }; var dest = Mapper.Map<RootEntityDto, RootEntity>(src); Assert.That(dest.Id, Is.EqualTo(1)); Assert.That(dest.Name, Is.EqualTo("root entity")); Assert.That(dest.ExternalEntities, Is.Not.Null); Assert.That(dest.DetailEntities.Count(), Is.EqualTo(2)); }