File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,11 +47,28 @@ public void MappingToReadonlyPropertyWhenPocoDetectRegression()
4747 student . Name . ShouldBe ( "John" ) ;
4848 }
4949
50+ [ TestMethod ]
51+ public void MappingToReadonlyAutoPropertyPrimitiveOrImmutableType ( )
52+ {
53+ var studentDto = new StudentDtoOrigin { Name = "Marta" } ;
54+ var UseDestinationValue = studentDto . Adapt < StudentOrigin > ( ) ;
55+ var NotUseDestinationValue = studentDto . Adapt < StudentOriginNoUseDestinationValue > ( ) ;
56+
57+ UseDestinationValue . Name . ShouldBe ( studentDto . Name ) ;
58+ NotUseDestinationValue . Name . ShouldBe ( "John" ) ; // not modified Name == "John" - origin value
59+ }
60+
61+ #region TestClasses
62+
63+ public class StudentOriginNoUseDestinationValue
64+ {
65+ public string Name { get ; } = "John" ; // readonly primitive type autoproperty
66+ }
5067
5168 public class StudentOrigin
5269 {
5370 [ UseDestinationValue ]
54- public string Name { get ; } = "John" ; // only readonly
71+ public string Name { get ; } = "John" ; // readonly primitive type autoproperty
5572 }
5673
5774 public class StudentDtoOrigin
@@ -93,5 +110,7 @@ public class InvoiceDto
93110 public IEnumerable < int > Numbers { get ; set ; }
94111 public ICollection < string > Strings { get ; set ; }
95112 }
113+
114+ #endregion TestClasses
96115 }
97116}
You can’t perform that action at this time.
0 commit comments