Browse Source

SimpleMapper fixed

pull/254/head v1.3.1
Sebastian Stehle 8 years ago
parent
commit
798eb12b6f
  1. 2
      src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs
  2. 2
      src/Squidex.Infrastructure/Reflection/SimpleMapper.cs
  3. 14
      tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs

2
src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs

@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Core.Apps
public sealed class LanguagesConfig : IFieldPartitioning
{
public static readonly LanguagesConfig Empty = new LanguagesConfig(ImmutableDictionary<Language, LanguageConfig>.Empty, null, false);
public static readonly LanguagesConfig English = LanguagesConfig.Build(Language.EN);
public static readonly LanguagesConfig English = Build(Language.EN);
private readonly ImmutableDictionary<Language, LanguageConfig> languages;
private readonly LanguageConfig master;

2
src/Squidex.Infrastructure/Reflection/SimpleMapper.cs

@ -137,7 +137,7 @@ namespace Squidex.Infrastructure.Reflection
new PropertyAccessor(sourceClassType, sourceProperty),
new PropertyAccessor(targetClassType, targetProperty)));
}
else if (sourceType.Implements<IConvertible>())
else if (sourceType.Implements<IConvertible>() || targetType.Implements<IConvertible>())
{
Mappers.Add(new ConversionPropertyMapper(
new PropertyAccessor(sourceClassType, sourceProperty),

14
tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs

@ -100,6 +100,20 @@ namespace Squidex.Infrastructure.Reflection
Assert.Equal(0, obj2.P3);
}
[Fact]
public void Should_map_nullables()
{
var obj1 = new Class1<bool?, bool?>
{
P1 = true,
P2 = true
};
var obj2 = SimpleMapper.Map(obj1, new Class2<bool, bool>());
Assert.True(obj2.P2);
Assert.False(obj2.P3);
}
[Fact]
public void Should_map_when_convertible_is_null()
{

Loading…
Cancel
Save