public void Base_Configuration_Map_Condition_Applies_To_Derived_Class() { TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .Map(dest => dest.Name, src => src.Name + "_Suffix", src => src.Name == "SourceName") .Compile(); TypeAdapterConfig <DerivedPoco, SimpleDto> .Clear(); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt <SimpleDto>(source); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBe(source.Name + "_Suffix"); var source2 = new DerivedPoco { Id = new Guid(), Name = "SourceName3" }; dto = TypeAdapter.Adapt <SimpleDto>(source2); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBeNull(); }
public void Base_Configuration_Map_Condition_Applies_To_Derived_Class() { TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig() .Map(dest => dest.Name, src => src.Name + "_Suffix", src => src.Name == "SourceName") .Compile(); TypeAdapterConfig<DerivedPoco, DerivedDto>.NewConfig() .Inherits<SimplePoco, SimpleDto>() .Compile(); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt<DerivedDto>(source); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBe(source.Name + "_Suffix"); var source2 = new DerivedPoco { Id = new Guid(), Name = "SourceName3" }; var dto2 = TypeAdapter.Adapt<DerivedDto>(source2); dto2.Id.ShouldBe(source.Id); dto2.Name.ShouldBeNull(); }
public void Ignores_Are_Derived_From_Base_Configurations() { TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .Ignore(dest => dest.Name); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt <SimpleDto>(source); dto.Id.ShouldEqual(source.Id); dto.Name.ShouldBeNull(); }
public void Base_Configuration_Applies_To_Derived_Class_If_No_Explicit_Configuration() { TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .Map(dest => dest.Name, src => src.Name + "_Suffix"); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt <SimpleDto>(source); dto.Id.ShouldEqual(source.Id); dto.Name.ShouldEqual(source.Name + "_Suffix"); }
public void Base_Configuration_DestinationTransforms_Apply_To_Derived_Class() { TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .DestinationTransforms.Upsert <string>(x => x.Trim()); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName " }; var dto = TypeAdapter.Adapt <SimpleDto>(source); dto.Id.ShouldEqual(source.Id); dto.Name.ShouldEqual(source.Name.Trim()); }
public void Ignores_Are_Derived_From_Base_Dest_Configurations() { TypeAdapterConfig.GlobalSettings.AllowImplicitDestinationInheritance = true; TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .Map(dest => dest.Name, src => src.Name + "_Suffix"); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt <DerivedDto>(source); dto.Id.ShouldEqual(source.Id); dto.Name.ShouldEqual(source.Name + "_Suffix"); }
public void Base_Configuration_Applies_To_Derived_Class_If_No_Explicit_Configuration() { TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig() .Map(dest => dest.Name, src => src.Name + "_Suffix") .Compile(); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt<SimpleDto>(source); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBe(source.Name + "_Suffix"); }
public void Base_Configuration_DestinationTransforms_Apply_To_Derived_Class() { var config = TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig(); config.AddDestinationTransform((string x) => x.Trim()); config.Compile(); TypeAdapterConfig<DerivedPoco, SimpleDto>.Clear(); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName " }; var dto = TypeAdapter.Adapt<SimpleDto>(source); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBe(source.Name.Trim()); }
public void Base_Configuration_DestinationTransforms_Apply_To_Derived_Class() { var config = TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig(); config.AddDestinationTransform((string x) => x.Trim()); config.Compile(); TypeAdapterConfig <DerivedPoco, SimpleDto> .Clear(); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName " }; var dto = TypeAdapter.Adapt <SimpleDto>(source); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBe(source.Name.Trim()); }
public void Base_Configuration_Doesnt_Apply_To_Derived_Class_If_Explicit_Configuration_Exists() { TypeAdapterConfig <DerivedPoco, SimpleDto> .NewConfig().Compile(); TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .Map(dest => dest.Name, src => src.Name + "_Suffix") .Compile(); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt <SimpleDto>(source); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBe(source.Name); }
public void Ignores_Are_Overridden_By_Derived_Configurations() { TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig() .Ignore(dest => dest.Name); TypeAdapterConfig <DerivedPoco, DerivedDto> .NewConfig() .Inherits <SimplePoco, SimpleDto>() .Map(dest => dest.Name, src => src.Name); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt <DerivedDto>(source); dto.Id.ShouldEqual(source.Id); dto.Name.ShouldEqual(source.Name); }
public void Ignores_Are_Derived_From_Base_Configurations() { TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig() .Ignore(dest => dest.Name) .Compile(); TypeAdapterConfig<DerivedPoco, DerivedDto>.NewConfig() .Inherits<SimplePoco, SimpleDto>() .Compile(); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt<DerivedDto>(source); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBeNull(); }
public void Ignores_Are_Derived_From_Base_Dest_Configurations() { TypeAdapterConfig.GlobalSettings.AllowImplicitDestinationInheritance = true; TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig() .Map(dest => dest.Name, src => src.Name + "_Suffix") .Compile(); var source = new DerivedPoco { Id = new Guid(), Name = "SourceName" }; var dto = TypeAdapter.Adapt<DerivedDto>(source); dto.Id.ShouldBe(source.Id); dto.Name.ShouldBe(source.Name + "_Suffix"); }