public void Mapping_Basic_Poco_Succeeds() { TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig(); IAdapter instance = TypeAdapter.GetInstance(); var source = new SimplePoco { Id = new Guid(), Name = "Test" }; var destination = instance.Adapt <SimpleDto>(source); destination.Name.ShouldEqual(source.Name); }
public void Passed_Condition_Primitive_Does_Map() { TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .Map(dest => dest.Name, src => src.Name, cond => cond.Name == "TestName"); var poco = new SimplePoco { Id = Guid.NewGuid(), Name = "TestName" }; IAdapter instance = TypeAdapter.GetInstance(); SimpleDto dto = instance.Adapt <SimplePoco, SimpleDto>(poco); dto.Id.ShouldEqual(poco.Id); dto.Name.ShouldEqual("TestName"); }
public void False_Condition_Primitive_Does_Not_Map() { TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .Map(dest => dest.Name, src => src.Name, cond => false) .Compile(); var poco = new SimplePoco { Id = Guid.NewGuid(), Name = "TestName" }; IAdapter instance = TypeAdapter.GetInstance(); SimpleDto dto = instance.Adapt <SimplePoco, SimpleDto>(poco); dto.Id.ShouldBe(poco.Id); dto.Name.ShouldBeNull(); }