Skip to content

Commit

Permalink
fix(tests): Run tests on English culture Set the current thread cultu…
Browse files Browse the repository at this point in the history
…re to english, as for systems on others cultures, some tests were failing.
  • Loading branch information
daniel-pons committed Sep 6, 2021
1 parent 8a3fcc7 commit c770664
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions OptimizelySDK.Tests/OptimizelySDK.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<Compile Include="TestBucketer.cs" />
<Compile Include="BucketerTest.cs" />
<Compile Include="ProjectConfigTest.cs" />
<Compile Include="TestSetup.cs" />
<Compile Include="UtilsTests\ConditionParserTest.cs" />
<Compile Include="UtilsTests\EventTagUtilsTest.cs" />
<Compile Include="UtilsTests\ExceptionExtensionsTest.cs" />
Expand Down
25 changes: 25 additions & 0 deletions OptimizelySDK.Tests/TestSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NUnit.Framework;
using System.Globalization;
using System.Threading;

namespace OptimizelySDK.Tests
{
[SetUpFixture]
public class TestSetup
{
[SetUp]
public void Init()
{
/* There are some issues doing assertions on tests with floating point numbers using the .ToString()
* method, as it's culture dependent. EG: TestGetFeatureVariableValueForTypeGivenFeatureFlagIsNotEnabledForUser,
* assigning the culture to English will make this kind of tests to work on others culture based systems. */
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
}

[TearDown]
public void Cleanup()
{
// Empty, but required: https://nunit.org/nunitv2/docs/2.6.4/setupFixture.html
}
}
}

0 comments on commit c770664

Please sign in to comment.