Fix DecimalPropertyEditor on non-English systems (#20215)
* Directly convert from double or float when possible. Also fixes string parsing to work on all cultures. Fixes #20214 * Added unit tests to verify behaviour. --------- Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a6e736849f
commit
493dd1dc78
@@ -26,8 +26,10 @@ public class DecimalPropertyValueEditorTests
|
||||
{ 123, 123m },
|
||||
{ -123, -123m },
|
||||
{ 123.45d, 123.45m },
|
||||
{ 123.45f, 123.45m },
|
||||
{ "123.45", 123.45m },
|
||||
{ "1234.56", 1234.56m },
|
||||
{ "1,234.56", 1234.56m },
|
||||
{ "123,45", 12345m },
|
||||
{ "1.234,56", null },
|
||||
{ "123 45", null },
|
||||
@@ -49,6 +51,18 @@ public class DecimalPropertyValueEditorTests
|
||||
}
|
||||
}
|
||||
|
||||
[SetCulture("it-IT")]
|
||||
[SetUICulture("it-IT")]
|
||||
[TestCase("123,45", 123.45)]
|
||||
[TestCase("1.234,56", 1234.56)]
|
||||
[TestCase("123.45", 12345)]
|
||||
[TestCase("1,234.56", null)]
|
||||
public void Can_Parse_Values_From_Editor_Using_Culture_With_Non_EnUs_Decimal_Separator(object value, decimal? expected)
|
||||
{
|
||||
var fromEditor = FromEditor(value);
|
||||
Assert.AreEqual(expected, fromEditor);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Parse_Values_To_Editor()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user