File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
AgileMapper.UnitTests/Configuration Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,29 @@ public void ShouldNotMapCollectionElementsToNull()
157157 }
158158 }
159159
160+ [ Fact ]
161+ public void ShouldMapCollectionElementNestedPropertiesToNull ( )
162+ {
163+ using ( var mapper = Mapper . CreateNew ( ) )
164+ {
165+ mapper . WhenMapping
166+ . To < Address > ( )
167+ . If ( ( o , a ) => a . Line1 == null )
168+ . MapToNull ( ) ;
169+
170+ var source = new [ ]
171+ {
172+ new CustomerViewModel { AddressLine1 = null } ,
173+ new CustomerViewModel { AddressLine1 = "Hello!" }
174+ } ;
175+ var result = mapper . Map ( source ) . ToANew < IEnumerable < MysteryCustomer > > ( ) ;
176+
177+ result . First ( ) . Address . ShouldBeNull ( ) ;
178+ result . Second ( ) . Address . ShouldNotBeNull ( ) ;
179+ result . Second ( ) . Address . Line1 . ShouldBe ( "Hello!" ) ;
180+ }
181+ }
182+
160183 [ Fact ]
161184 public void ShouldErrorIfConditionsAreConfiguredForTheSameType ( )
162185 {
You can’t perform that action at this time.
0 commit comments