AssertConfigurationIsValid error message is wrong for child properties #206

Closed
joshka opened this Issue May 14, 2012 · 2 comments

Projects

None yet

2 participants

@joshka

The following test throws an exception (expected), however the message is pointing at the wrong type

AutoMapper.AutoMapperConfigurationException : The following property on AutoMapperMessageBugTests.DestChild cannot be mapped:

Should read:

AutoMapper.AutoMapperConfigurationException : The following property on AutoMapperMessageBugTests.Source cannot be mapped:

And the following part of the exception

Add a custom mapping expression, ignore, add a custom resolver, or modify the destination type AutoMapperMessageBugTests.SourceChild

should read:

Add a custom mapping expression, ignore, add a custom resolver, or modify the destination type AutoMapperMessageBugTests.Dest

[TestFixture]
public class CustomProfileTests
{
    [Test]
    public void ConfigurationIsValid()
    {
        Mapper.AddProfile<CustomProfile>();
        Mapper.AssertConfigurationIsValid();
    }
}

public class CustomProfile : Profile
{
    protected override void Configure()
    {
        CreateMap<Source, Dest>();
    }
}

public class Source
{
    public SourceChild Child { get; set; }
}

public class SourceChild
{
}

public class Dest
{
    public DestChild Child { get; set; }
}

public class DestChild
{
}
@joshka

For context, the full exception message is:

AutoMapper.AutoMapperConfigurationException : The following property on AutoMapperMessageBugTests.DestChild cannot be mapped:
Child
Add a custom mapping expression, ignore, add a custom resolver, or modify the destination type AutoMapperMessageBugTests.SourceChild.
Context:
Mapping to property Child of type AutoMapperMessageBugTests.DestChild from source type AutoMapperMessageBugTests.SourceChild
Mapping to type AutoMapperMessageBugTests.Dest from source type AutoMapperMessageBugTests.Source
Exception of type 'AutoMapper.AutoMapperConfigurationException' was thrown.

@joshka

Also, it might be nice if the exception messages were "mapping foo to bar" instead of "mapping bar from foo", because english reads left to right and the call to mapper.Map has the properties this way as well. I'm not sure that this warrants an issue of its own, or discussion. (feel free to fork this issue if needs be).

@jbogard jbogard closed this in 2c402b0 Sep 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment