Skip to content

Instantly share code, notes, and snippets.

@gerektoolhy
Created February 19, 2013 12:50
Show Gist options
  • Save gerektoolhy/4985605 to your computer and use it in GitHub Desktop.
Save gerektoolhy/4985605 to your computer and use it in GitHub Desktop.
Second call to Mapper.CreaateMap redefiens the map from OrderDtoString to Order, but the actual property mappings stay untouched. The order is created with status "InProgress", but the old mapping which returns Status.Complete is still in place, thus the line dto.Status.ShouldEqual(Status.Complete) is true.
[Test]
public void ShouldNotAllowToOverrideConfig()
{
Mapper.CreateMap<OrderDtoString, Order>()
.ForMember(y => y.Status, x => x.MapFrom(t => Status.Complete));
Mapper.CreateMap<OrderDtoString, Order>();
var order = new OrderDtoString
{
Status = "InProgress",
};
var dto = Mapper.Map<OrderDtoString, Order>(order);
dto.Status.ShouldEqual(Status.Complete);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment