Skip to content

Commit c770664

Browse files
committed
fix(tests): Run tests on English culture Set the current thread culture to english, as for systems on others cultures, some tests were failing.
1 parent 8a3fcc7 commit c770664

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

OptimizelySDK.Tests/OptimizelySDK.Tests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
<Compile Include="TestBucketer.cs" />
9898
<Compile Include="BucketerTest.cs" />
9999
<Compile Include="ProjectConfigTest.cs" />
100+
<Compile Include="TestSetup.cs" />
100101
<Compile Include="UtilsTests\ConditionParserTest.cs" />
101102
<Compile Include="UtilsTests\EventTagUtilsTest.cs" />
102103
<Compile Include="UtilsTests\ExceptionExtensionsTest.cs" />

OptimizelySDK.Tests/TestSetup.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using NUnit.Framework;
2+
using System.Globalization;
3+
using System.Threading;
4+
5+
namespace OptimizelySDK.Tests
6+
{
7+
[SetUpFixture]
8+
public class TestSetup
9+
{
10+
[SetUp]
11+
public void Init()
12+
{
13+
/* There are some issues doing assertions on tests with floating point numbers using the .ToString()
14+
* method, as it's culture dependent. EG: TestGetFeatureVariableValueForTypeGivenFeatureFlagIsNotEnabledForUser,
15+
* assigning the culture to English will make this kind of tests to work on others culture based systems. */
16+
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
17+
}
18+
19+
[TearDown]
20+
public void Cleanup()
21+
{
22+
// Empty, but required: https://nunit.org/nunitv2/docs/2.6.4/setupFixture.html
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)