Skip to content

Commit

Permalink
Releases/1.4 preview (#136)
Browse files Browse the repository at this point in the history
* v1.4-preview branch

* Bugs/issue129 (#131)

* Short-circuiting expression replacement when target and replacement are the same
* Specifically retrieving ToTarget data sources where required
* Returning existing arrays in ICollection.ToArray if possible

* Updating release notes

* Adding v1.4-preview NuGet package

* Bugs/issue130 (#132)

* Method renames / Extending typed ToTarget test, re: #129, #130

* Extending typed ToTarget test / Adding failing ToTarget mapping callback test / Compiling ConfigInfo.ToMappingData caller

* Improving MappingCreationContext ctors

* Moving MappingCreationContext logic into MappingCreationContext

* Tidying

* Removing unused method / Tidying

* Support for mapping callbacks within non-implementation pair, ToTarget mappings

* Support for implementation pair ToTarget configuration
Removing unnecessary package from EF2 Core test project

* Continued

* Tidying

* Fixing support for ToTarget data sources in repeated mappings

* Handling null configured implementation ToTarget data sources

* Updating to v1.4-preview2

* Features/configured source member validation (#134)

* Erroring if redundant matching source member is configured

* Improving configured data source validation
Support for same-typed configured data source for otherwise-unconstructable target members

* Fixing ToTarget complex type entry dictionary mapping, re: #133

* Skipping existing dictionary value checks when target is definitely unpopulated

* Code coverage changes / Tidying

* Updating to v1.4-preview3

* Fixing build

* Fixing complex type dictionary merging

* Updating release notes

* Updating to v1.4

* v1.4 NuGet package
  • Loading branch information
SteveWilkes authored May 3, 2019
1 parent a0ee13d commit e4777d6
Show file tree
Hide file tree
Showing 57 changed files with 1,151 additions and 352 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
<Reference Include="Microsoft.Extensions.Caching.Memory, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Caching.Memory.2.0.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Configuration.Abstractions.2.0.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.2.0.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll</HintPath>
</Reference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,48 @@ public void ShouldErrorIfDuplicateDataSourceIsConfigured()
[Fact]
public void ShouldErrorIfRedundantDataSourceIsConfigured()
{
Should.Throw<MappingConfigurationException>(() =>
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.From<PublicProperty<int>>()
.To<PublicField<string>>()
.Map(pp => pp.Value, pf => pf.Value);
}
});

configEx.Message.ShouldContain("PublicProperty<int>.Value");
configEx.Message.ShouldContain("PublicField<string>.Value");
configEx.Message.ShouldContain("does not need to be configured");
}

[Fact]
public void ShouldErrorIfRedundantConstructorParameterDataSourceIsConfigured()
{
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.From<PublicProperty<int>>()
.To<PublicCtor<string>>()
.Map(ctx => ctx.Source.Value)
.ToCtor<string>();
}
});

configEx.Message.ShouldContain("PublicProperty<int>.Value");
configEx.Message.ShouldContain("will automatically be mapped");
configEx.Message.ShouldContain("target constructor parameter");
configEx.Message.ShouldContain("PublicCtor<string>.value");
configEx.Message.ShouldContain("does not need to be configured");
}

[Fact]
public void ShouldErrorIfRedundantDerivedTypeDataSourceIsConfigured()
{
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
Expand All @@ -129,6 +170,8 @@ public void ShouldErrorIfRedundantDataSourceIsConfigured()
.To(x => x.Value);
}
});

configEx.Message.ShouldContain("already has configured data source");
}

[Fact]
Expand Down Expand Up @@ -262,6 +305,24 @@ public void ShouldErrorIfUnconvertibleConstructorValueConstantSpecified()
configurationException.Message.ShouldContain("Unable to convert");
}

[Fact]
public void ShouldErrorIfUnconvertibleConstructorSourceValueSpecified()
{
var configurationException = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.From<PublicProperty<int>>()
.To<PublicCtor<Guid>>()
.Map(ctx => ctx.Source.Value)
.ToCtor<Guid>();
}
});

configurationException.Message.ShouldContain("Unable to convert");
}

[Fact]
public void ShouldErrorIfSimpleTypeConfiguredForComplexTarget()
{
Expand All @@ -281,6 +342,25 @@ public void ShouldErrorIfSimpleTypeConfiguredForComplexTarget()
"Person.Id of type 'Guid' cannot be mapped to target type 'Address'");
}

[Fact]
public void ShouldErrorIfSimpleTypeConfiguredForComplexConstructorParameter()
{
var configurationException = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.From<PublicField<int>>()
.To<PublicCtor<Address>>()
.Map(ctx => ctx.Source.Value)
.ToCtor<Address>();
}
});

configurationException.Message.ShouldContain(
"PublicField<int>.Value of type 'int' cannot be mapped to target type 'Address'");
}

[Fact]
public void ShouldErrorIfSimpleTypeConfiguredForEnumerableTarget()
{
Expand All @@ -300,6 +380,25 @@ public void ShouldErrorIfSimpleTypeConfiguredForEnumerableTarget()
"PublicField<int>.Value of type 'int' cannot be mapped to target type 'int[]'");
}

[Fact]
public void ShouldErrorIfSimpleTypeConfiguredForEnumerableConstructorParameter()
{
var configurationException = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.From<PublicField<string>>()
.To<PublicCtor<int[]>>()
.Map(ctx => ctx.Source.Value)
.ToCtor("value");
}
});

configurationException.Message.ShouldContain(
"PublicField<string>.Value of type 'string' cannot be mapped to target type 'int[]'");
}

[Fact]
public void ShouldErrorIfUnconvertibleEnumerableElementTypeConfigured()
{
Expand All @@ -308,9 +407,9 @@ public void ShouldErrorIfUnconvertibleEnumerableElementTypeConfigured()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.From<PublicField<PublicField<int>[]>>()
.From<PublicTwoFields<PublicField<int>[], int[]>>()
.To<PublicField<int[]>>()
.Map(s => s.Value, t => t.Value);
.Map(s => s.Value1, t => t.Value);
}
});

Expand Down
Loading

0 comments on commit e4777d6

Please sign in to comment.