SlapperAutoMapper / Slapper.AutoMapper

Slapper.AutoMapper maps dynamic data to static types. Slap your data into submission!
MIT License
287 stars 76 forks source link

Mapping fails when grandchild's name contains part of child's name #26

Closed geirsagberg closed 8 years ago

geirsagberg commented 8 years ago

Here is the test I wrote, that fails:

public class MatchingChildNameTests
{
    public class SubMember
    {
        public int Id { get; set; }
    }

    public class Member
    {
        public int Id { get; set; }
        public IList<SubMember> SubMembers { get; set; }
    }

    public class Club
    {
        public int Id { get; set; }
        public IList<Member> Members { get; set; }
    }

    [Test]
    public void Can_map_grandchild_with_parts_of_same_name_as_child()
    {
        var data = new List<Dictionary<string, object>> {
            new Dictionary<string, object> {
                {"Id", 1},
                {"Members_Id", 1},
                {"Members_SubMembers_Id", 1}
            }
        };

        var club = AutoMapper.MapDynamic<Club>(data).Single();

        Assert.That(club.Members.Count == 1);
        Assert.NotNull(club.Members[0].SubMembers);
        Assert.That(club.Members[0].SubMembers.Count == 1);
    }
}
odelvalle commented 8 years ago

Thanks @geirsagberg I will include your merge in next release...