File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ public void AddMaps(params Type[] typesFromAssembliesContainingMappingDefinition
8686 private void AddMapsCore ( IEnumerable < Assembly > assembliesToScan )
8787 {
8888 var allTypes = assembliesToScan . Where ( a => ! a . IsDynamic ) . SelectMany ( a => a . GetDefinedTypes ( ) ) . ToArray ( ) ;
89- var autoMapAttributeProfile = new NamedProfile ( "AutoMapAttributeProfile" ) ;
89+ var autoMapAttributeProfile = new NamedProfile ( nameof ( AutoMapAttribute ) ) ;
9090
9191 foreach ( var type in allTypes )
9292 {
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public void Should_map()
3636 [ Fact ]
3737 public void Should_validate_successfully ( )
3838 {
39- typeof ( AutoMapperConfigurationException ) . ShouldNotBeThrownBy ( ( ) => Configuration . AssertConfigurationIsValid ( "AutoMapAttributeProfile" ) ) ;
39+ typeof ( AutoMapperConfigurationException ) . ShouldNotBeThrownBy ( ( ) => Configuration . AssertConfigurationIsValid ( nameof ( AutoMapAttribute ) ) ) ;
4040 }
4141 }
4242
@@ -71,7 +71,35 @@ public void Should_reverse_map()
7171 [ Fact ]
7272 public void Should_validate_successfully ( )
7373 {
74- typeof ( AutoMapperConfigurationException ) . ShouldNotBeThrownBy ( ( ) => Configuration . AssertConfigurationIsValid ( "AutoMapAttributeProfile" ) ) ;
74+ typeof ( AutoMapperConfigurationException ) . ShouldNotBeThrownBy ( ( ) => Configuration . AssertConfigurationIsValid ( nameof ( AutoMapAttribute ) ) ) ;
75+ }
76+ }
77+
78+ public class When_duplicating_map_configuration_with_code_and_attribute : NonValidatingSpecBase
79+ {
80+ public class Source
81+ {
82+ public int Value { get ; set ; }
83+ }
84+
85+ [ AutoMap ( typeof ( Source ) ) ]
86+ public class Dest
87+ {
88+ public int Value { get ; set ; }
89+ }
90+
91+ protected override MapperConfiguration Configuration { get ; } = new MapperConfiguration ( cfg =>
92+ {
93+ cfg . CreateMissingTypeMaps = false ;
94+ cfg . AddMaps ( typeof ( When_specifying_map_and_reverse_map_with_attribute ) ) ;
95+ cfg . CreateMap < Source , Dest > ( ) ;
96+ } ) ;
97+
98+ [ Fact ]
99+ public void Should_not_validate_successfully ( )
100+ {
101+ typeof ( DuplicateTypeMapConfigurationException ) . ShouldBeThrownBy ( ( ) => Configuration . AssertConfigurationIsValid ( ) ) ;
102+
75103 }
76104 }
77105 }
You can’t perform that action at this time.
0 commit comments