jediwhale / fitsharp

Functional testing tools for .NET

Home Page:http://fitsharp.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Culture invariant

GibSral opened this issue · comments

Hi,
I have an issue concerning doubles.
I live in germany and my Windows is set to the german language. So i get 2,5 instead of 2.5.
In my Test-Scripts I use the invariant representation (2.5) wich results in a failing Assertion when I use Check in a script table.
Converting a double parameter of a method call will also result in an invalid value(2.5 is interpreted as 25)

I tried using a config file:

<suiteConfig>
   <Culture>
      <Name>invariant</Name>
   </Culture>
   <Settings>
      <ApartmentState>STA</ApartmentState>
      <Behavior>std</Behavior>
      <CodePage>1200</CodePage>
      <Runner>fitSharp.Slim.Service.Runner</Runner>
      <XmlOutput>myResult.xml</XmlOutput>
   </Settings>
</suiteConfig>

But this doesn´t help either.

Can someone help me please?

Thanks in advance

Lars

I have the same problem with script tables and checks. It is impossible to test any double values, and setting the culture to "Invariant" using the config file does not help. My main display language in Windows is English, but the number formatting uses comma as decimal separator (I live in Sweden).

For the time being I've worked around the issue by writing a specific fixture that sets the thread culture to invariant and including that in e.g. the SetUp page:

// Fixture
public class Culture
{
  public Culture()
  {}

  public Culture(string cultureName)
  {
    Current = cultureName;
  }

  public string Current
  {
    get { return Thread.CurrentThread.CurrentCulture.DisplayName; }
    set { Thread.CurrentThread.CurrentCulture = new CultureInfo(Fix(value)); }
  }

  private static string Fix(string cultureName)
  {
    var nonNullCultureName = cultureName ?? String.Empty;

    return nonNullCultureName.ToLowerInvariant().Equals("invariant")
              ? String.Empty
              : cultureName;
  }
}
# In e.g. SetUp page
!|Script|Culture|Invariant|

Hope that helps.

fixed to use suite configuration culture setting for slim tests