diff --git a/AgileMapper.UnitTests/AgileMapper.UnitTests.csproj b/AgileMapper.UnitTests/AgileMapper.UnitTests.csproj
index 9c8402f51..af79a4380 100644
--- a/AgileMapper.UnitTests/AgileMapper.UnitTests.csproj
+++ b/AgileMapper.UnitTests/AgileMapper.UnitTests.csproj
@@ -96,8 +96,30 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -180,7 +202,7 @@
-
+
diff --git a/AgileMapper.UnitTests/Configuration/WhenConfiguringNameMatching.cs b/AgileMapper.UnitTests/Configuration/WhenConfiguringNameMatching.cs
index aeab6c395..286193cde 100644
--- a/AgileMapper.UnitTests/Configuration/WhenConfiguringNameMatching.cs
+++ b/AgileMapper.UnitTests/Configuration/WhenConfiguringNameMatching.cs
@@ -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;
diff --git a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByFilter.cs b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByFilter.cs
index 5ed307c0a..ad98fa64e 100644
--- a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByFilter.cs
+++ b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByFilter.cs
@@ -1,6 +1,7 @@
namespace AgileObjects.AgileMapper.UnitTests.Configuration
{
using System;
+ using AgileMapper.Extensions.Internal;
using TestClasses;
using Xunit;
@@ -331,8 +332,7 @@ public void ShouldIgnoreMembersBySourceTypeTargetTypeAndPathMatch()
mapper.WhenMapping
.From>()
.To>()
- .IgnoreTargetMembersWhere(member =>
- member.Path.Equals("Value.Line2", StringComparison.OrdinalIgnoreCase));
+ .IgnoreTargetMembersWhere(member => member.Path.EqualsIgnoreCase("Value.Line2"));
var matchingSource = new PublicField { Value = new Address { Line1 = "Here", Line2 = "Here!" } };
var nonMatchingSource = new { Value = new Address { Line1 = "There", Line2 = "There!" } };
diff --git a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByGlobalFilter.cs b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByGlobalFilter.cs
index 802192323..b0936b8e0 100644
--- a/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByGlobalFilter.cs
+++ b/AgileMapper.UnitTests/Configuration/WhenIgnoringMembersByGlobalFilter.cs
@@ -1,7 +1,7 @@
namespace AgileObjects.AgileMapper.UnitTests.Configuration
{
using System;
- using System.Linq;
+ using AgileMapper.Extensions.Internal;
using Shouldly;
using TestClasses;
using Xunit;
@@ -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)
diff --git a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs
index 2bff412ef..182d2e3ef 100644
--- a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs
+++ b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs
@@ -14,7 +14,7 @@ public void ShouldErrorIfCustomMemberKeyIsNull()
var configEx = Should.Throw(() =>
{
Mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To>()
.MapFullKey(null)
.To(pf => pf.Value);
@@ -29,7 +29,7 @@ public void ShouldErrorIfCustomMemberNameIsNull()
var configEx = Should.Throw(() =>
{
Mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To>()
.MapMemberNameKey(null)
.To(pf => pf.Value);
@@ -46,12 +46,12 @@ public void ShouldErrorIfIgnoredMemberIsGivenCustomMemberKey()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To()
.Ignore(p => p.Id);
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To()
.MapFullKey("PersonId")
.To(p => p.Id);
@@ -69,12 +69,12 @@ public void ShouldErrorIfIgnoredMemberIsGivenCustomMemberName()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To>()
.Ignore(pf => pf.Value);
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To>()
.MapMemberNameKey("ValueValue")
.To(pf => pf.Value);
@@ -92,13 +92,13 @@ public void ShouldErrorIfCustomDataSourceMemberIsGivenCustomMemberKey()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To()
.Map((d, p) => d.Count)
.To(p => p.Name);
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To()
.MapFullKey("PersonName")
.To(p => p.Name);
@@ -116,13 +116,13 @@ public void ShouldErrorIfCustomDataSourceMemberIsGivenCustomMemberName()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To()
.Map((d, p) => d.Count)
.To(p => p.Name);
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To()
.MapMemberNameKey("PersonName")
.To(p => p.Name);
@@ -159,43 +159,43 @@ public void ShouldErrorIfAnUnreadableSourceMemberIsSpecified()
}
[Fact]
- public void ShouldErrorIfMemberNamesAreFlattenedAndSeparatedGlobally()
+ public void ShouldErrorIfRedundantSourceSeparatorIsConfigured()
{
var configEx = Should.Throw(() =>
{
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(() =>
{
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(() =>
{
@@ -203,33 +203,32 @@ public void ShouldErrorIfMemberNamesAreFlattenedAndSeparatedForASpecificTargetTy
{
mapper.WhenMapping
.Dictionaries
- .To>>()
- .UseFlattenedMemberNames()
- .UseMemberNameSeparator("_");
+ .UseMemberNameSeparator("+")
+ .UseFlattenedTargetMemberNames();
}
});
- configEx.Message.ShouldContain("PublicField>");
- configEx.Message.ShouldContain("flattened");
+ configEx.Message.ShouldContain("global");
+ configEx.Message.ShouldContain("separated with '+'");
}
[Fact]
- public void ShouldErrorIfMemberNamesAreSeparatedAndFlattenedForASpecificTargetType()
+ public void ShouldErrorIfDifferentSeparatorsSpecifiedForASpecificTargetType()
{
var configEx = Should.Throw(() =>
{
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
- .To>>()
- .UseMemberNameSeparator("+")
- .UseFlattenedMemberNames();
+ .FromDictionaries
+ .To>>()
+ .UseMemberNameSeparator("-")
+ .UseMemberNameSeparator("_");
}
});
- configEx.Message.ShouldContain("PublicProperty>");
- configEx.Message.ShouldContain("separated with '+'");
+ configEx.Message.ShouldContain("PublicField>");
+ configEx.Message.ShouldContain("separated with '-'");
}
[Fact]
@@ -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(() =>
+ {
+ 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()
{
diff --git a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringSourceDictionaryMapping.cs b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringSourceDictionaryMapping.cs
index b7214e9f2..a29ba1fc4 100644
--- a/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringSourceDictionaryMapping.cs
+++ b/AgileMapper.UnitTests/Dictionaries/Configuration/WhenConfiguringSourceDictionaryMapping.cs
@@ -14,7 +14,7 @@ public void ShouldUseACustomFullDictionaryKeyForARootMember()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To>()
.MapFullKey("BoomDiddyBoom")
.To(pf => pf.Value);
@@ -32,7 +32,7 @@ public void ShouldUseACustomFullDictionaryKeyForANestedMember()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.OnTo>>()
.MapFullKey("BoomDiddyMcBoom")
.To(pf => pf.Value.Value);
@@ -54,7 +54,7 @@ public void ShouldUseCustomMemberNameDictionaryKeysForRootMembers()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.Over()
.MapMemberNameKey("HouseNumber")
.To(a => a.Line1)
@@ -81,7 +81,7 @@ public void ShouldUseACustomMemberNameDictionaryKeyForANestedMember()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionariesWithValueType()
.ToANew()
.MapMemberNameKey("HouseName")
.To(a => a.Line1);
@@ -99,7 +99,7 @@ public void ShouldUseACustomMemberNameDictionaryKeyForANestedArrayMember()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionaries
.To>()
.MapMemberNameKey("Strings")
.To(pp => pp.Value);
@@ -125,7 +125,7 @@ public void ShouldApplyNonDictionarySpecificConfiguration()
using (var mapper = Mapper.CreateNew())
{
mapper.WhenMapping
- .Dictionaries
+ .FromDictionariesWithValueType