@@ -143,5 +143,71 @@ public void TryParseLengthUnitUsEnglish(string s, bool expected)
143
143
bool actual = Length . TryParse ( s , usEnglish , out Length _ ) ;
144
144
Assert . Equal ( expected , actual ) ;
145
145
}
146
+
147
+ [ Theory ]
148
+ [ InlineData ( "1 ng" , "en-US" , 1 , MassUnit . Nanogram ) ]
149
+ [ InlineData ( "1 нг" , "ru-RU" , 1 , MassUnit . Nanogram ) ]
150
+ [ InlineData ( "1 g" , "en-US" , 1 , MassUnit . Gram ) ]
151
+ [ InlineData ( "1 г" , "ru-RU" , 1 , MassUnit . Gram ) ]
152
+ [ InlineData ( "1 kg" , "en-US" , 1 , MassUnit . Kilogram ) ]
153
+ [ InlineData ( "1 кг" , "ru-RU" , 1 , MassUnit . Kilogram ) ]
154
+ public void ParseMassWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue ( string str , string cultureName , double expectedValue , Enum expectedUnit )
155
+ {
156
+ var actual = Mass . Parse ( str , new CultureInfo ( cultureName ) ) ;
157
+
158
+ Assert . Equal ( expectedUnit , actual . Unit ) ;
159
+ Assert . Equal ( expectedValue , actual . Value ) ;
160
+ }
161
+
162
+ [ Theory ]
163
+ [ InlineData ( "1 nm" , "en-US" , 1 , LengthUnit . Nanometer ) ]
164
+ [ InlineData ( "1 нм" , "ru-RU" , 1 , LengthUnit . Nanometer ) ]
165
+ [ InlineData ( "1 m" , "en-US" , 1 , LengthUnit . Meter ) ]
166
+ [ InlineData ( "1 м" , "ru-RU" , 1 , LengthUnit . Meter ) ]
167
+ [ InlineData ( "1 km" , "en-US" , 1 , LengthUnit . Kilometer ) ]
168
+ [ InlineData ( "1 км" , "ru-RU" , 1 , LengthUnit . Kilometer ) ]
169
+ public void ParseLengthWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue ( string str , string cultureName , double expectedValue , Enum expectedUnit )
170
+ {
171
+ var actual = Length . Parse ( str , new CultureInfo ( cultureName ) ) ;
172
+
173
+ Assert . Equal ( expectedUnit , actual . Unit ) ;
174
+ Assert . Equal ( expectedValue , actual . Value ) ;
175
+ }
176
+
177
+ [ Theory ]
178
+ [ InlineData ( "1 µN" , "en-US" , 1 , ForceUnit . Micronewton ) ]
179
+ [ InlineData ( "1 мкН" , "ru-RU" , 1 , ForceUnit . Micronewton ) ]
180
+ [ InlineData ( "1 N" , "en-US" , 1 , ForceUnit . Newton ) ]
181
+ [ InlineData ( "1 Н" , "ru-RU" , 1 , ForceUnit . Newton ) ]
182
+ [ InlineData ( "1 kN" , "en-US" , 1 , ForceUnit . Kilonewton ) ]
183
+ [ InlineData ( "1 кН" , "ru-RU" , 1 , ForceUnit . Kilonewton ) ]
184
+ public void ParseForceWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue ( string str , string cultureName , double expectedValue , Enum expectedUnit )
185
+ {
186
+ var actual = Force . Parse ( str , new CultureInfo ( cultureName ) ) ;
187
+
188
+ Assert . Equal ( expectedUnit , actual . Unit ) ;
189
+ Assert . Equal ( expectedValue , actual . Value ) ;
190
+ }
191
+
192
+ [ Theory ]
193
+ [ InlineData ( "1 b" , "en-US" , 1 , InformationUnit . Bit ) ]
194
+ [ InlineData ( "1 b" , "ru-RU" , 1 , InformationUnit . Bit ) ]
195
+ [ InlineData ( "1 B" , "en-US" , 1 , InformationUnit . Byte ) ]
196
+ [ InlineData ( "1 B" , "ru-RU" , 1 , InformationUnit . Byte ) ]
197
+ [ InlineData ( "1 Mb" , "en-US" , 1 , InformationUnit . Megabit ) ]
198
+ [ InlineData ( "1 Mb" , "ru-RU" , 1 , InformationUnit . Megabit ) ]
199
+ [ InlineData ( "1 Mib" , "en-US" , 1 , InformationUnit . Mebibit ) ]
200
+ [ InlineData ( "1 Mib" , "ru-RU" , 1 , InformationUnit . Mebibit ) ]
201
+ [ InlineData ( "1 MB" , "en-US" , 1 , InformationUnit . Megabyte ) ]
202
+ [ InlineData ( "1 MB" , "ru-RU" , 1 , InformationUnit . Megabyte ) ]
203
+ [ InlineData ( "1 MiB" , "en-US" , 1 , InformationUnit . Mebibyte ) ]
204
+ [ InlineData ( "1 MiB" , "ru-RU" , 1 , InformationUnit . Mebibyte ) ]
205
+ public void ParseInformationWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue ( string str , string cultureName , decimal expectedValue , Enum expectedUnit )
206
+ {
207
+ var actual = Information . Parse ( str , new CultureInfo ( cultureName ) ) ;
208
+
209
+ Assert . Equal ( expectedUnit , actual . Unit ) ;
210
+ Assert . Equal ( expectedValue , actual . Value ) ;
211
+ }
146
212
}
147
213
}
0 commit comments