File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
src/AutoMapper.Collection.Tests Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public void Should_not_throw_exception_for_nonexisting_types()
1717 } ) ;
1818 IMapper mapper = new Mapper ( configuration ) ;
1919
20- var system = new System
20+ var originalModel = new System
2121 {
2222 Name = "My First System" ,
2323 Contacts = new List < Contact >
@@ -36,10 +36,16 @@ public void Should_not_throw_exception_for_nonexisting_types()
3636 }
3737 } ;
3838
39- var model = mapper . Map < SystemViewModel > ( system ) ;
40- model . Name . Should ( ) . Be ( system . Name ) ;
41- model . Contacts . Single ( ) . Name . Should ( ) . Be ( system . Contacts . Single ( ) . Name ) ;
42- model . Contacts . Single ( ) . Emails . Single ( ) . Address . Should ( ) . Be ( system . Contacts . Single ( ) . Emails . Single ( ) . Address ) ;
39+ var originalEmail = originalModel . Contacts . Single ( ) . Emails . Single ( ) ;
40+
41+ var assertModel = mapper . Map < SystemViewModel > ( originalModel ) ;
42+ assertModel . Name . Should ( ) . Be ( originalModel . Name ) ;
43+ assertModel . Contacts . Single ( ) . Name . Should ( ) . Be ( originalModel . Contacts . Single ( ) . Name ) ;
44+ assertModel . Contacts . Single ( ) . Emails . Single ( ) . Address . Should ( ) . Be ( originalModel . Contacts . Single ( ) . Emails . Single ( ) . Address ) ;
45+
46+ mapper . Map ( assertModel , originalModel ) ;
47+ // This tests if equality was found and mapped to pre-existing object and not defaulting to AM and clearing and regenerating the list
48+ originalModel . Contacts . Single ( ) . Emails . Single ( ) . Should ( ) . Be ( originalEmail ) ;
4349 }
4450
4551 public class System
You can’t perform that action at this time.
0 commit comments