Created
February 19, 2013 12:50
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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