public void Explicit_Mapping_Requirement_Throws_Before_Mapping_Attempted() { TypeAdapterConfig.GlobalSettings.RequireExplicitMapping = true; TypeAdapterConfig.GlobalSettings.RequireDestinationMemberSource = true; var simplePoco = new WhenAddingCustomMappings.SimplePoco { Id = Guid.NewGuid(), Name = "TestName" }; Assert.Throws <AggregateException>(() => { for (int i = 0; i < 100; i++) { Parallel.Invoke( () => { TypeAdapterConfig <WhenAddingCustomMappings.SimplePoco, WeirdPoco> .NewConfig() .Map(dest => dest.IHaveADifferentId, src => src.Id) .Map(dest => dest.MyNamePropertyIsDifferent, src => src.Name) .Ignore(dest => dest.Children); }, () => { TypeAdapter.Adapt <WeirdPoco>(simplePoco); } ); } }); //Type should map at the end because mapping has completed. TypeAdapter.Adapt <WhenAddingCustomMappings.SimplePoco, WeirdPoco>(simplePoco); }
public void Race_Condition_Produces_Error() { TypeAdapterConfig.GlobalSettings.RequireDestinationMemberSource = true; var simplePoco = new WhenAddingCustomMappings.SimplePoco { Id = Guid.NewGuid(), Name = "TestName" }; var exception = Assert.Throws <AggregateException>(() => { for (int i = 0; i < 100; i++) { Parallel.Invoke( () => { TypeAdapterConfig <WhenAddingCustomMappings.SimplePoco, WeirdPoco> .NewConfig() .Map(dest => dest.IHaveADifferentId, src => src.Id) .Map(dest => dest.MyNamePropertyIsDifferent, src => src.Name) .Ignore(dest => dest.Children); }, () => { TypeAdapter.Adapt <WeirdPoco>(simplePoco); } ); } }); exception.InnerException.ShouldBeType(typeof(ArgumentOutOfRangeException)); }
public void Explicit_Mapping_Requirement_Throws_Before_Mapping_Attempted() { TypeAdapterConfig.GlobalSettings.RequireExplicitMapping = true; TypeAdapterConfig.GlobalSettings.RequireDestinationMemberSource = true; var simplePoco = new WhenAddingCustomMappings.SimplePoco { Id = Guid.NewGuid(), Name = "TestName" }; Assert.Throws<AggregateException>(() => { for (int i = 0; i < 100; i++) { Parallel.Invoke( () => { TypeAdapterConfig<WhenAddingCustomMappings.SimplePoco, WeirdPoco>.NewConfig() .Map(dest => dest.IHaveADifferentId, src => src.Id) .Map(dest => dest.MyNamePropertyIsDifferent, src => src.Name) .Ignore(dest => dest.Children); }, () => { TypeAdapter.Adapt<WeirdPoco>(simplePoco); } ); } }); //Type should map at the end because mapping has completed. TypeAdapter.Adapt<WhenAddingCustomMappings.SimplePoco, WeirdPoco>(simplePoco); }
public void Race_Condition_Produces_Error() { TypeAdapterConfig.GlobalSettings.RequireDestinationMemberSource = true; var simplePoco = new WhenAddingCustomMappings.SimplePoco {Id = Guid.NewGuid(), Name = "TestName"}; var exception = Assert.Throws<AggregateException>(() => { for (int i = 0; i < 100; i++) { Parallel.Invoke( () => { TypeAdapterConfig<WhenAddingCustomMappings.SimplePoco, WeirdPoco>.NewConfig() .Map(dest => dest.IHaveADifferentId, src => src.Id) .Map(dest => dest.MyNamePropertyIsDifferent, src => src.Name) .Ignore(dest => dest.Children); }, () => { TypeAdapter.Adapt<WeirdPoco>(simplePoco); } ); } }); exception.InnerException.ShouldBeType(typeof(ArgumentOutOfRangeException)); }
public void Types_Map_Successfully_If_Mapping_Applied_First() { TypeAdapterConfig.GlobalSettings.RequireDestinationMemberSource = true; var simplePoco = new WhenAddingCustomMappings.SimplePoco {Id = Guid.NewGuid(), Name = "TestName"}; TypeAdapterConfig<WhenAddingCustomMappings.SimplePoco, WeirdPoco>.NewConfig() .Map(dest => dest.IHaveADifferentId, src => src.Id) .Map(dest => dest.MyNamePropertyIsDifferent, src => src.Name) .Ignore(dest => dest.Children); TypeAdapter.Adapt<WhenAddingCustomMappings.SimplePoco, WeirdPoco>(simplePoco); }
public void Types_Map_Successfully_If_Mapping_Applied_First() { TypeAdapterConfig.GlobalSettings.RequireDestinationMemberSource = true; var simplePoco = new WhenAddingCustomMappings.SimplePoco { Id = Guid.NewGuid(), Name = "TestName" }; TypeAdapterConfig <WhenAddingCustomMappings.SimplePoco, WeirdPoco> .NewConfig() .Map(dest => dest.IHaveADifferentId, src => src.Id) .Map(dest => dest.MyNamePropertyIsDifferent, src => src.Name) .Ignore(dest => dest.Children); TypeAdapter.Adapt <WhenAddingCustomMappings.SimplePoco, WeirdPoco>(simplePoco); }