martinrue/Tinyweb — Issue #10: Localization issues
Author: reiroldan
Created: 2012-01-16 15:26:19+00:00
State: open

Hi,

There are a few places where you should take into consideration the current locale in order to get the correct value for parameters. For example, the current unit tests fail at 3 points when using double or decimal types with a system where the decimal separator is a "," (coma) instead of a "." (period).

The following tests:
ParseAcceptHeader_MultipleTypesAndPriorities_FindsCorrectTypesAndPriorities
ParseAcceptHeader_SingleTypeAndPriority_FindsCorrectTypeAndPriority
HttpPOST_WithAllParameterSources_CallsHandlerPostMethodAndReturnsCorrectData

Are the ones that fail immediately, these can be fixed quite easily by replacing:

method: Extensions.ParseAcceptHeader

From:
mimeTypes.Add(preferenceParts.ElementAt(0), Convert.ToDouble(preferenceParts.ElementAt(1).Substring(2)));
To:
mimeTypes.Add(preferenceParts.ElementAt(0), Convert.ToDouble(preferenceParts.ElementAt(1).Substring(2), CultureInfo.InvariantCulture));

And

method: ArgumentBuilder.changeType

From:
return Convert.ChangeType(value, conversionType);
To:
return Convert.ChangeType(value, conversionType, CultureInfo.InvariantCulture);

Nice framework over all. Good work :)