asiftasleem / nbuilder

Automatically exported from code.google.com/p/nbuilder
0 stars 0 forks source link

GetRandom.Decimal throws exception on system with comma as decimal separator #57

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Calling GetRandom.Decimal on a system with a culture/locale that uses comma 
instead of dot as the decimal separator throws a System.FormatException:

System.Reflection.TargetInvocationException : Exception has been thrown by the 
target of an invocation.
  ----> System.FormatException : Input string was not in a correct format.

This is caused by the RandomGenerator doing a Convert.ToDecimal on a string 
with a dot decimal separator, which blows up. The fix to this is to specify 
CultureInfo.InvariantCulture as the second argument to the Convert.ToDecimal 
call.

A patch is attached with a test that confirms the bug (no matter which culture 
the system uses) and the fix.

/Erik

Original issue reported on code.google.com by erik.oj...@gmail.com on 10 Nov 2010 at 8:37

Attachments:

GoogleCodeExporter commented 8 years ago
Read up on the project guidelines on the wiki, and created a new patch where 
the test name follows the Method_Scenario_Expectation convention.

Original comment by erik.oj...@gmail.com on 10 Nov 2010 at 8:48

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by garethdo...@googlemail.com on 11 Nov 2010 at 9:37