Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
e4a0a6c
Support for flattening single-member nested complex types to an untyp…
SteveWilkes Dec 6, 2017
680f0ee
Support for mapping from non-generic IDictionary<,> implementations, …
SteveWilkes Dec 6, 2017
c9794b5
Test coverage for conversion of dynamic object simple-type member val…
SteveWilkes Dec 6, 2017
07e987f
Organising source Dictionary mapping tests
SteveWilkes Dec 6, 2017
070faf3
Removing need to cast IDictionary<,> source objects when accessing keys
SteveWilkes Dec 6, 2017
519b7fa
Test coverage for mapping a null string dynamic member
SteveWilkes Dec 6, 2017
2fa18bf
Support for mapping untyped dictionary complex type entries to comple…
SteveWilkes Dec 7, 2017
43011e6
Renaming dictionary key matchers for clarity / Using efficient string…
SteveWilkes Dec 7, 2017
3aa65d1
Supporting mapping from dynamic members with flattened names to neste…
SteveWilkes Dec 7, 2017
2b2f47b
Supporting flattened source Dictionary keys by default, without confi…
SteveWilkes Dec 7, 2017
a15496c
Test coverage for mapping from a dynamic to a simple type enumerable …
SteveWilkes Dec 8, 2017
dbc5ff5
Support for mapping dynamic non-identifiable complex type collection …
SteveWilkes Dec 8, 2017
ca0445f
Support for mapping from dynamic, underscored-index enumerable elemen…
SteveWilkes Dec 8, 2017
abb306b
Organising Dictionary classes
SteveWilkes Dec 8, 2017
70b3f14
Test coverage for mapping from flattened dynamic members to nested co…
SteveWilkes Dec 9, 2017
0ade134
Test coverage for mapping from dynamics to new root enumerables
SteveWilkes Dec 9, 2017
949279e
Short-circuiting mappings from dictionaries to recursive members / In…
SteveWilkes Dec 9, 2017
f049f04
Test coverage for mapping from a dynamic null complex type collection…
SteveWilkes Dec 9, 2017
ef37bfb
Support for mapping from object-valued IDictionary<,> IDictionary<,> …
SteveWilkes Dec 10, 2017
bf8282d
Test coverage for namming ExpandoObject (not IDictionary<,>) in throw…
SteveWilkes Dec 10, 2017
b96e451
Support for mapping from nested dynamic members to nested complex typ…
SteveWilkes Dec 10, 2017
2da3961
Extending test coverage for mapping from nested dynamics to nested co…
SteveWilkes Dec 10, 2017
ab27437
Support for mapping to ValueType-valued IDictionary<,>s / Using Shoul…
SteveWilkes Dec 10, 2017
caa11ab
Support for IDictionary<,> -> complex type enumerable mapping short-c…
SteveWilkes Dec 10, 2017
066a02f
Test coverage for mapping over root complex type members
SteveWilkes Dec 10, 2017
6fb02d3
Extending enum -> enum mapping test coverage
SteveWilkes Dec 12, 2017
a9c3fdb
Start of mapping to dynamic test coverage
SteveWilkes Dec 12, 2017
56f8108
Extending map-to-dynamic test coverage
SteveWilkes Dec 12, 2017
17d6fb7
Start of test coverage for mapping over dynamics / Skipping 'assign t…
SteveWilkes Dec 12, 2017
e3903f4
Extending coverage for mapping over dynamic root members
SteveWilkes Dec 12, 2017
941363a
Start of merging to dynamics support
SteveWilkes Dec 12, 2017
957bee0
Restricting WhenMapping.DictionariesWithValueType<TValue> mappings to…
SteveWilkes Dec 12, 2017
1bc103a
Extending member matching test coverage
SteveWilkes Dec 15, 2017
e6f33c9
Selecting flattened source members from parent contexts to map to nes…
SteveWilkes Dec 15, 2017
1cbb503
Support for mapping flattened members from parent contexts to nested …
SteveWilkes Dec 15, 2017
60c19ec
Fixing broken tests / Moving internal extension methods into dedicate…
SteveWilkes Dec 16, 2017
7f3283f
Extending test coverage for mapping to nested dynamic members
SteveWilkes Dec 16, 2017
87253c0
Test coverage for mapping to root enumerable<dynamic>
SteveWilkes Dec 16, 2017
c09cf7a
Test coverage for mapping derived complex type collection elements to…
SteveWilkes Dec 16, 2017
a96fcf2
Separating global dictionary configuration from source dictionary con…
SteveWilkes Dec 16, 2017
425ff9c
Support for mapping nested members to flattened, underscore-separated…
SteveWilkes Dec 16, 2017
f63774f
Support for mapping over nested ExpandoObject members
SteveWilkes Dec 16, 2017
5dc1a34
Beginning of dynamic configuration API / Ensuring dynamic configurati…
SteveWilkes Dec 16, 2017
36f70a7
Support for configuring creation-mapping-specific custom dynamic sour…
SteveWilkes Dec 16, 2017
814c0f2
Test coverage for mapping onto a nested dynamic from a nested Dictionary
SteveWilkes Dec 16, 2017
ddc43fc
Support for mapping from complex type enumerables onto nested target …
SteveWilkes Dec 16, 2017
7019743
Support for configuring custom member names for source dynamic mappings
SteveWilkes Dec 16, 2017
7b84301
Support for mapping from dynamics with configured member name parts /…
SteveWilkes Dec 16, 2017
bff4b2b
Support for using custom member name separators for source dynamics /…
SteveWilkes Dec 17, 2017
698d70e
Erroring if redundant element key patterns are configured / Organisin…
SteveWilkes Dec 17, 2017
8f27b71
Test coverage for configuration error when configuring a redundant el…
SteveWilkes Dec 17, 2017
b93a7ed
Erroring is redundant member name separator globally configured for d…
SteveWilkes Dec 17, 2017
2d409a7
Differentiating between global and source-only dictionary (and dynami…
SteveWilkes Dec 17, 2017
43416be
Differentiating between source-only and global dynamic configuration
SteveWilkes Dec 17, 2017
a895534
Support for differentiating global and source-specific dynamic member…
SteveWilkes Dec 17, 2017
d1cd5ad
Fixing dynamic mapping separator selection
SteveWilkes Dec 17, 2017
2907cf0
Support for mapping from a collection of structs to a target dynamic …
SteveWilkes Dec 18, 2017
8d020a3
Test coverage for mapping over a dynamic from an unmappable struct ty…
SteveWilkes Dec 18, 2017
744f1d8
Start of dynamic over enumerable mapping
SteveWilkes Dec 18, 2017
69f643c
Extending dynamic over enumerables test coverage
SteveWilkes Dec 18, 2017
19873fd
Separating dictionary and dynamic configurator classes / Derived dyna…
SteveWilkes Dec 18, 2017
c52a53a
Test coverage for mapping from dynamics to derived types based on the…
SteveWilkes Dec 18, 2017
84898d6
Start of target dynamic mapping configuration tests / Support for Map…
SteveWilkes Dec 18, 2017
3cf4cb1
Adding target dynamic configuration API classes / Start of target dyn…
SteveWilkes Dec 18, 2017
9481298
Support for custom, source-type-specific dynamic enumerable element p…
SteveWilkes Dec 19, 2017
865e570
Support for conditional custom mapping to custom ExpandoObject target…
SteveWilkes Dec 19, 2017
f34f87d
Test coverage for various conditional mappings to custom dynamic targ…
SteveWilkes Dec 19, 2017
b95736a
Ensuring target dictionary configuration is not applied to target dyn…
SteveWilkes Dec 19, 2017
fe677b3
Test coverage ensuring target dynamic config isn't applied to target …
SteveWilkes Dec 19, 2017
136b92e
Test coverage for non-conflict of target dictionary and dynamic confi…
SteveWilkes Dec 19, 2017
00d73b4
Flattening objects using ToANew<dynamic>()
SteveWilkes Dec 19, 2017
5756d76
Tidying
SteveWilkes Dec 20, 2017
7ebdf2b
Fixing flattening test
SteveWilkes Dec 20, 2017
8c59fbf
Handling null entries in complex type collections being flattened or …
SteveWilkes Dec 20, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions AgileMapper.UnitTests/AgileMapper.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,30 @@
<Compile Include="Configuration\Inline\WhenValidatingMappingsInline.cs" />
<Compile Include="Configuration\Inline\WhenViewingMappingPlans.cs" />
<Compile Include="Configuration\WhenViewingMappingPlans.cs" />
<Compile Include="Dictionaries\WhenMergingObjectsFromDictionaries.cs" />
<Compile Include="Dictionaries\WhenOverwritingObjectsFromDictionaries.cs" />
<Compile Include="Dictionaries\WhenMappingFromDictionariesOnToComplexTypes.cs" />
<Compile Include="Dictionaries\WhenMappingFromDictionariesOnToEnumerableMembers.cs" />
<Compile Include="Dictionaries\WhenMappingFromDictionariesOverComplexTypes.cs" />
<Compile Include="Dictionaries\WhenMappingFromDictionariesToNewComplexTypeMembers.cs" />
<Compile Include="Dictionaries\WhenMappingFromDictionariesToNewEnumerableMembers.cs" />
<Compile Include="Dictionaries\WhenMappingFromDictionariesToNewEnumerables.cs" />
<Compile Include="Dynamics\Configuration\WhenConfiguringDynamicMappingIncorrectly.cs" />
<Compile Include="Dynamics\Configuration\WhenConfiguringSourceDynamicMapping.cs" />
<Compile Include="Dynamics\Configuration\WhenConfiguringTargetDynamicMapping.cs" />
<Compile Include="Dynamics\WhenMappingFromDynamicsOverComplexTypeMembers.cs" />
<Compile Include="Dynamics\WhenMappingFromDynamicsOverComplexTypes.cs" />
<Compile Include="Dynamics\WhenMappingFromDynamicsOverEnumerableMembers.cs" />
<Compile Include="Dynamics\WhenMappingFromDynamicsOverEnumerables.cs" />
<Compile Include="Dynamics\WhenMappingFromDynamicsToNewComplexTypeMembers.cs" />
<Compile Include="Dynamics\WhenMappingFromDynamicsToNewComplexTypes.cs" />
<Compile Include="Dynamics\WhenMappingFromDynamicsToNewEnumerableMembers.cs" />
<Compile Include="Dynamics\WhenMappingFromDynamicsToNewEnumerables.cs" />
<Compile Include="Dynamics\WhenMappingOnToDynamics.cs" />
<Compile Include="Dynamics\WhenMappingOnToDynamicMembers.cs" />
<Compile Include="Dynamics\WhenMappingOverDynamicMembers.cs" />
<Compile Include="Dynamics\WhenMappingOverDynamics.cs" />
<Compile Include="Dynamics\WhenMappingToNewEnumerablesOfDynamic.cs" />
<Compile Include="Dynamics\WhenMappingToNewDynamicMembers.cs" />
<Compile Include="Dynamics\WhenMappingToNewDynamics.cs" />
<Compile Include="Extensions\WhenEquatingExpressions.cs" />
<Compile Include="MapperCloning\WhenCloningConstructorDataSources.cs" />
<Compile Include="MapperCloning\WhenCloningMemberIgnores.cs" />
Expand Down Expand Up @@ -180,7 +202,7 @@
<Compile Include="WhenAnalysingCollections.cs" />
<Compile Include="MapperCloning\WhenCloningDataSources.cs" />
<Compile Include="WhenFlatteningObjects.cs" />
<Compile Include="Dictionaries\WhenMappingNewObjectsFromDictionaries.cs" />
<Compile Include="Dictionaries\WhenMappingFromDictionariesToNewComplexTypes.cs" />
<Compile Include="Dictionaries\WhenMappingFromDictionaryMembers.cs" />
<Compile Include="Dictionaries\WhenMappingOnToDictionaries.cs" />
<Compile Include="Dictionaries\WhenMappingOnToDictionaryMembers.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using AgileMapper.Configuration;
using AgileMapper.Extensions;
using AgileMapper.Extensions.Internal;
using Shouldly;
using TestClasses;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace AgileObjects.AgileMapper.UnitTests.Configuration
{
using System;
using AgileMapper.Extensions.Internal;
using TestClasses;
using Xunit;

Expand Down Expand Up @@ -331,8 +332,7 @@ public void ShouldIgnoreMembersBySourceTypeTargetTypeAndPathMatch()
mapper.WhenMapping
.From<PublicField<Address>>()
.To<PublicProperty<Address>>()
.IgnoreTargetMembersWhere(member =>
member.Path.Equals("Value.Line2", StringComparison.OrdinalIgnoreCase));
.IgnoreTargetMembersWhere(member => member.Path.EqualsIgnoreCase("Value.Line2"));

var matchingSource = new PublicField<Address> { Value = new Address { Line1 = "Here", Line2 = "Here!" } };
var nonMatchingSource = new { Value = new Address { Line1 = "There", Line2 = "There!" } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace AgileObjects.AgileMapper.UnitTests.Configuration
{
using System;
using System.Linq;
using AgileMapper.Extensions.Internal;
using Shouldly;
using TestClasses;
using Xunit;
Expand Down Expand Up @@ -209,8 +209,7 @@ public void ShouldIgnoreMembersByPathMatch()
var source = new { Address = new Address { Line1 = "ONE!", Line2 = "TWO!" } };

mapper.WhenMapping
.IgnoreTargetMembersWhere(member =>
member.Path.Equals("Value.Line1", StringComparison.OrdinalIgnoreCase));
.IgnoreTargetMembersWhere(member => member.Path.EqualsIgnoreCase("Value.Line1"));

mapper.WhenMapping
.From(source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void ShouldErrorIfCustomMemberKeyIsNull()
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
Mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<PublicField<string>>()
.MapFullKey(null)
.To(pf => pf.Value);
Expand All @@ -29,7 +29,7 @@ public void ShouldErrorIfCustomMemberNameIsNull()
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
Mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<PublicField<string>>()
.MapMemberNameKey(null)
.To(pf => pf.Value);
Expand All @@ -46,12 +46,12 @@ public void ShouldErrorIfIgnoredMemberIsGivenCustomMemberKey()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<Person>()
.Ignore(p => p.Id);

mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<Person>()
.MapFullKey("PersonId")
.To(p => p.Id);
Expand All @@ -69,12 +69,12 @@ public void ShouldErrorIfIgnoredMemberIsGivenCustomMemberName()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<PublicField<string>>()
.Ignore(pf => pf.Value);

mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<PublicField<string>>()
.MapMemberNameKey("ValueValue")
.To(pf => pf.Value);
Expand All @@ -92,13 +92,13 @@ public void ShouldErrorIfCustomDataSourceMemberIsGivenCustomMemberKey()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<Person>()
.Map((d, p) => d.Count)
.To(p => p.Name);

mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<Person>()
.MapFullKey("PersonName")
.To(p => p.Name);
Expand All @@ -116,13 +116,13 @@ public void ShouldErrorIfCustomDataSourceMemberIsGivenCustomMemberName()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<Person>()
.Map((d, p) => d.Count)
.To(p => p.Name);

mapper.WhenMapping
.Dictionaries
.FromDictionaries
.To<Person>()
.MapMemberNameKey("PersonName")
.To(p => p.Name);
Expand Down Expand Up @@ -159,77 +159,76 @@ public void ShouldErrorIfAnUnreadableSourceMemberIsSpecified()
}

[Fact]
public void ShouldErrorIfMemberNamesAreFlattenedAndSeparatedGlobally()
public void ShouldErrorIfRedundantSourceSeparatorIsConfigured()
{
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.UseFlattenedMemberNames()
.UseMemberNameSeparator("+");
.FromDictionaries
.UseMemberNameSeparator(".");
}
});

configEx.Message.ShouldContain("already");
configEx.Message.ShouldContain("global");
configEx.Message.ShouldContain("flattened");
configEx.Message.ShouldContain("'.'");
}

[Fact]
public void ShouldErrorIfMemberNamesAreSeparatedAndFlattenedGlobally()
public void ShouldErrorIfMemberNamesAreFlattenedAndSeparatedGlobally()
{
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.UseMemberNameSeparator("+")
.UseFlattenedMemberNames();
.FromDictionaries
.UseFlattenedTargetMemberNames()
.UseMemberNameSeparator("+");
}
});

configEx.Message.ShouldContain("global");
configEx.Message.ShouldContain("separated with '+'");
configEx.Message.ShouldContain("flattened");
}

[Fact]
public void ShouldErrorIfMemberNamesAreFlattenedAndSeparatedForASpecificTargetType()
public void ShouldErrorIfMemberNamesAreSeparatedAndFlattenedGlobally()
{
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.To<PublicField<PublicProperty<string>>>()
.UseFlattenedMemberNames()
.UseMemberNameSeparator("_");
.UseMemberNameSeparator("+")
.UseFlattenedTargetMemberNames();
}
});

configEx.Message.ShouldContain("PublicField<PublicProperty<string>>");
configEx.Message.ShouldContain("flattened");
configEx.Message.ShouldContain("global");
configEx.Message.ShouldContain("separated with '+'");
}

[Fact]
public void ShouldErrorIfMemberNamesAreSeparatedAndFlattenedForASpecificTargetType()
public void ShouldErrorIfDifferentSeparatorsSpecifiedForASpecificTargetType()
{
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.To<PublicProperty<PublicField<int>>>()
.UseMemberNameSeparator("+")
.UseFlattenedMemberNames();
.FromDictionaries
.To<PublicField<PublicProperty<string>>>()
.UseMemberNameSeparator("-")
.UseMemberNameSeparator("_");
}
});

configEx.Message.ShouldContain("PublicProperty<PublicField<int>>");
configEx.Message.ShouldContain("separated with '+'");
configEx.Message.ShouldContain("PublicField<PublicProperty<string>>");
configEx.Message.ShouldContain("separated with '-'");
}

[Fact]
Expand Down Expand Up @@ -280,6 +279,24 @@ public void ShouldErrorIfAnElementKeyPartHasMultipleIndexPlaceholders()
"pattern must contain a single 'i' character as a placeholder for the enumerable index");
}

[Fact]
public void ShouldErrorIfRedundantGlobalElementKeyPartIsConfigured()
{
var configEx = Should.Throw<MappingConfigurationException>(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
.Dictionaries
.UseElementKeyPattern("[i]");
}
});

configEx.Message.ShouldContain("already");
configEx.Message.ShouldContain("global");
configEx.Message.ShouldContain("[i]");
}

[Fact]
public void ShouldErrorIfCustomTargetMemberKeyIsNotAConstant()
{
Expand Down
Loading