File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 11namespace AgileObjects . AgileMapper . UnitTests
22{
33 using System ;
4+ using System . Collections . Generic ;
45 using Shouldly ;
56 using TestClasses ;
67 using Validation ;
@@ -111,6 +112,40 @@ public void ShouldErrorIfComplexTypeMemberIsUnconstructable()
111112 }
112113 }
113114
115+ [ Fact ]
116+ public void ShouldNotErrorIfConstructableComplexTypeMemberHasNoMatchingSource ( )
117+ {
118+ using ( var mapper = Mapper . CreateNew ( ) )
119+ {
120+ mapper . WhenMapping
121+ . From < CustomerViewModel > ( )
122+ . To < Customer > ( )
123+ . Ignore ( c => c . Title , c => c . Address . Line2 ) ;
124+
125+ mapper . GetPlanFor < CustomerViewModel > ( ) . ToANew < Customer > ( ) ;
126+
127+ Should . NotThrow ( ( ) => mapper . ThrowNowIfAnyMappingPlanIsIncomplete ( ) ) ;
128+ }
129+ }
130+
131+ [ Fact ]
132+ public void ShouldErrorIfEnumerableMemberHasNonEnumerableSource ( )
133+ {
134+ using ( var mapper = Mapper . CreateNew ( ) )
135+ {
136+ mapper
137+ . GetPlanFor < PublicField < Address > > ( )
138+ . ToANew < PublicProperty < ICollection < string > > > ( ) ;
139+
140+ var validationEx = Should . Throw < MappingValidationException > ( ( ) =>
141+ mapper . ThrowNowIfAnyMappingPlanIsIncomplete ( ) ) ;
142+
143+ validationEx . Message . ShouldContain ( "PublicField<Address> -> PublicProperty<ICollection<string>>" ) ;
144+ validationEx . Message . ShouldContain ( "Unmapped target members" ) ;
145+ validationEx . Message . ShouldContain ( "PublicProperty<ICollection<string>>.Value" ) ;
146+ }
147+ }
148+
114149 [ Fact ]
115150 public void ShouldShowMultipleIncompleteCachedMappingPlans ( )
116151 {
You can’t perform that action at this time.
0 commit comments