@@ -50,70 +50,50 @@ private enum CustomUnit
50
50
// ReSharper restore UnusedMember.Local
51
51
}
52
52
53
- // These cultures all use a comma for the radix point
54
53
[ Theory ]
55
54
[ InlineData ( "de-DE" ) ]
56
55
[ InlineData ( "da-DK" ) ]
57
56
[ InlineData ( "es-AR" ) ]
58
57
[ InlineData ( "es-ES" ) ]
59
58
[ InlineData ( "it-IT" ) ]
60
- public void CommaRadixPointCultureFormatting ( string culture )
61
- {
62
- Assert . Equal ( "0,12 m" , Length . FromMeters ( 0.12 ) . ToUnit ( LengthUnit . Meter ) . ToString ( GetCulture ( culture ) ) ) ;
63
- }
64
-
65
- // These cultures all use a decimal point for the radix point
66
- [ Theory ]
67
59
[ InlineData ( "en-CA" ) ]
68
60
[ InlineData ( "en-US" ) ]
69
61
[ InlineData ( "ar-EG" ) ]
70
62
[ InlineData ( "en-GB" ) ]
71
63
[ InlineData ( "es-MX" ) ]
72
- public void DecimalRadixPointCultureFormatting ( string culture )
64
+ public void RadixPointCultureFormatting ( string cultureName )
73
65
{
74
- Assert . Equal ( "0.12 m" , Length . FromMeters ( 0.12 ) . ToUnit ( LengthUnit . Meter ) . ToString ( GetCulture ( culture ) ) ) ;
66
+ CultureInfo culture = GetCulture ( cultureName ) ;
67
+ string ds = culture . NumberFormat . NumberDecimalSeparator ;
68
+ Assert . Equal ( $ "0{ ds } 12 m", Length . FromMeters ( 0.12 ) . ToUnit ( LengthUnit . Meter ) . ToString ( culture ) ) ;
75
69
}
76
70
77
- // These cultures all use a comma in digit grouping
78
71
[ Theory ]
79
72
[ InlineData ( "en-CA" ) ]
73
+ [ InlineData ( "en-GB" ) ]
80
74
[ InlineData ( "en-US" ) ]
81
75
[ InlineData ( "ar-EG" ) ]
82
- [ InlineData ( "en-GB" ) ]
83
76
[ InlineData ( "es-MX" ) ]
84
- public void CommaDigitGroupingCultureFormatting ( string cultureName )
85
- {
86
- CultureInfo culture = GetCulture ( cultureName ) ;
87
- Assert . Equal ( "1,111 m" , Length . FromMeters ( 1111 ) . ToUnit ( LengthUnit . Meter ) . ToString ( culture ) ) ;
88
-
89
- // Feet/Inch and Stone/Pound combinations are only used (customarily) in the US, UK and maybe Ireland - all English speaking countries.
90
- // FeetInches returns a whole number of feet, with the remainder expressed (rounded) in inches. Same for SonePounds.
91
- Assert . Equal ( "2,222 ft 3 in" ,
92
- Length . FromFeetInches ( 2222 , 3 ) . FeetInches . ToString ( culture ) ) ;
93
- Assert . Equal ( "3,333 st 7 lb" ,
94
- Mass . FromStonePounds ( 3333 , 7 ) . StonePounds . ToString ( culture ) ) ;
95
- }
96
-
97
- // These cultures use a thin space in digit grouping
98
- [ Theory ]
99
77
[ InlineData ( "nn-NO" ) ]
100
78
[ InlineData ( "fr-FR" ) ]
101
- public void SpaceDigitGroupingCultureFormatting ( string culture )
102
- {
103
- // Note: the space used in digit groupings is actually a "thin space" Unicode character U+2009
104
- Assert . Equal ( "1 111 m" , Length . FromMeters ( 1111 ) . ToUnit ( LengthUnit . Meter ) . ToString ( GetCulture ( culture ) ) ) ;
105
- }
106
-
107
- // These cultures all use a decimal point in digit grouping
108
- [ Theory ]
109
79
[ InlineData ( "de-DE" ) ]
110
80
[ InlineData ( "da-DK" ) ]
111
81
[ InlineData ( "es-AR" ) ]
112
82
[ InlineData ( "es-ES" ) ]
113
83
[ InlineData ( "it-IT" ) ]
114
- public void DecimalPointDigitGroupingCultureFormatting ( string culture )
84
+ public void DigitGroupingCultureFormatting ( string cultureName )
115
85
{
116
- Assert . Equal ( "1.111 m" , Length . FromMeters ( 1111 ) . ToUnit ( LengthUnit . Meter ) . ToString ( GetCulture ( culture ) ) ) ;
86
+ CultureInfo culture = GetCulture ( cultureName ) ;
87
+ string gs = culture . NumberFormat . NumberGroupSeparator ;
88
+
89
+ Assert . Equal ( $ "1{ gs } 111 m", Length . FromMeters ( 1111 ) . ToUnit ( LengthUnit . Meter ) . ToString ( culture ) ) ;
90
+
91
+ // Feet/Inch and Stone/Pound combinations are only used (customarily) in the US, UK and maybe Ireland - all English speaking countries.
92
+ // FeetInches returns a whole number of feet, with the remainder expressed (rounded) in inches. Same for StonePounds.
93
+ Assert . Equal ( $ "2{ gs } 222 ft 3 in",
94
+ Length . FromFeetInches ( 2222 , 3 ) . FeetInches . ToString ( culture ) ) ;
95
+ Assert . Equal ( $ "3{ gs } 333 st 7 lb",
96
+ Mass . FromStonePounds ( 3333 , 7 ) . StonePounds . ToString ( culture ) ) ;
117
97
}
118
98
119
99
// Due to rounding, the values will result in the same string representation regardless of the number of significant digits (up to a certain point)
0 commit comments