File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
AgileMapper.UnitTests/Configuration Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ public class WhenConfiguringStringFormatting
88 {
99 // See https://github.com/agileobjects/AgileMapper/issues/23
1010 [ Fact ]
11- public void ShouldFormatDateTimesGlobally ( )
11+ public void ShouldFormatDateTimesMapperWide ( )
1212 {
1313 using ( var mapper = Mapper . CreateNew ( ) )
1414 {
@@ -21,5 +21,35 @@ public void ShouldFormatDateTimesGlobally()
2121 result . Value . ShouldBe ( source . Value . ToString ( "o" ) ) ;
2222 }
2323 }
24+
25+ [ Fact ]
26+ public void ShouldFormatDecimalsMapperWide ( )
27+ {
28+ using ( var mapper = Mapper . CreateNew ( ) )
29+ {
30+ mapper . WhenMapping
31+ . StringsFrom < decimal > ( c => c . FormatUsing ( "C" ) ) ;
32+
33+ var source = new PublicProperty < decimal > { Value = 1.99m } ;
34+ var result = mapper . Map ( source ) . ToANew < PublicField < string > > ( ) ;
35+
36+ result . Value . ShouldBe ( source . Value . ToString ( "C" ) ) ;
37+ }
38+ }
39+
40+ [ Fact ]
41+ public void ShouldFormatDoublesMapperWideUsingDecimalPlaces ( )
42+ {
43+ using ( var mapper = Mapper . CreateNew ( ) )
44+ {
45+ mapper . WhenMapping
46+ . StringsFrom < double > ( c => c . FormatUsing ( "0.00" ) ) ;
47+
48+ var source = new PublicProperty < double > { Value = 1 } ;
49+ var result = mapper . Map ( source ) . ToANew < PublicField < string > > ( ) ;
50+
51+ result . Value . ShouldBe ( "1.00" ) ;
52+ }
53+ }
2454 }
2555}
You can’t perform that action at this time.
0 commit comments