File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
tests/CsvHelper.Tests/Reading Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . Globalization ;
2+ using System . IO ;
3+ using System . Linq ;
4+ using CsvHelper . Configuration ;
5+ using Xunit ;
6+
7+ namespace CsvHelper . Tests . Reading
8+ {
9+ public class NumberReadingTests
10+ {
11+ [ Fact ]
12+ public void ReadDecimalDoubleCultureDeInvariantMix ( )
13+ {
14+ var input = new StringReader ( """
15+ MyMoney;YourMoney;MoreMoney;BigMoney
16+ 1.2;3.4;5.6;7.8
17+ """ ) ;
18+
19+ using var cr = new CsvReader ( input , new CsvConfiguration ( CultureInfo . InvariantCulture ) { Delimiter = ";" } ) ;
20+ var records = cr . GetRecords ( new
21+ {
22+ MyMoney = default ( decimal ) ,
23+ YourMoney = default ( double ) ,
24+ MoreMoney = default ( decimal ? ) ,
25+ BigMoney = default ( double ? ) ,
26+ } ) . ToArray ( ) ;
27+
28+ Assert . Equal ( 1.2m , records . Single ( ) . MyMoney ) ;
29+ Assert . Equal ( 3.4 , records . Single ( ) . YourMoney ) ;
30+ Assert . Equal ( 5.6m , records . Single ( ) . MoreMoney ) ;
31+ Assert . Equal ( 7.8 , records . Single ( ) . BigMoney ) ;
32+ }
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments