public void MapToInstanceWithInterface() { var dto = new InheritedDto { Id = 1, Name = "Test", DateOfBirth = new DateTime(1978, 12, 10), UnmappedSource = "Lorem ipsum" }; var config = new TypeAdapterConfig(); IInheritedDto target = new ImplementedDto(); dto.Adapt(target, config); target.ShouldNotBeNull(); target.ShouldSatisfyAllConditions( () => target.Id.ShouldBe(dto.Id), () => target.Name.ShouldBe(dto.Name), () => target.DateOfBirth.ShouldBe(dto.DateOfBirth), () => target.UnmappedTarget.ShouldBeNull() ); }
public void MapToInheritedInterfaceWithoutProperties() { var config = TypeAdapterConfig.GlobalSettings; TypeAdapterConfig <IInheritedDtoWithoutProperties, InheritedDto> .NewConfig() .Map(d => d.Id, s => s.Id) .Map(d => d.Name, s => s.Name) .IgnoreNonMapped(true); config.Compile(); /// doesn't reach this point var dto = new ImplementedDto { Id = 1, Name = "Test", DateOfBirth = new DateTime(1978, 12, 10), } as IInheritedDtoWithoutProperties; var idto = dto.Adapt <InheritedDto>(config); idto.Id.ShouldBe(dto.Id); idto.Name.ShouldBe(dto.Name); idto.DateOfBirth.ShouldBe(default);