mauricioaniche / restfulie.net

.net version of restfulie server
http://restfulie.caelum.com.br
Other
50 stars 17 forks source link

Fix [ShouldReturnMostQualifiedMediaTypeWhenDefaultHasQualifier] and [Sho... #2

Closed AbraaoAlves closed 12 years ago

AbraaoAlves commented 12 years ago

...uldReturnMostQualifiedMediaTypeWhenQualifierIsNotPresent] when culture is no en-US.

Example: when this project is used in a project with culture pt-Br, qualifier 0.9 is converted to 9.0

pedroreys commented 12 years ago

Hi Abraão, thank you for your pull request.

Do you mind doing us two things before we can merge your changes?

First, I understand it would be better to make it CultureInvariant instead of hard-coding en-US as the Culture, what do you think?

Also, can you please add a test to the AcceptHeaderToMediaTypeTests TestFixture that reproduces the issue that you are fixing?

Again, thanks for your help.

AbraaoAlves commented 12 years ago

Quando eu fiz o download do codigo fonte esses testes estavam quebrando:

ShouldReturnMostQualifiedMediaTypeWhenDefaultHasQualifier ShouldReturnMostQualifiedMediaTypeWhenQualifierIsNotPresent in Restfulie.Server.Tests.Negotiation.AcceptHeaderToMediaTypeTests.

Para ver isso é só setar a cultura na sua maquina ou no web.config para "pt-Br", onde a instrução Convert.ToDouble("0.8") retorna 8.0 (double) e Convert.ToDouble("0,8") retorna 0.8(double). Isso faz total diferença para o metodo private MostQualifiedMediaType.

Eu acho melhor setar a cultura no código mesmo porque o formato da string nunca muda e isso trás menos dor de cabeça para quem for utilizar-lo.

mauricioaniche commented 12 years ago

Hi Abraao,

Can you just write a test that shows that your implementation works regardless the culture of the server?