diff --git a/OptimizelySDK.Tests/OptimizelySDK.Tests.csproj b/OptimizelySDK.Tests/OptimizelySDK.Tests.csproj index 1a4e7df1..d5231738 100644 --- a/OptimizelySDK.Tests/OptimizelySDK.Tests.csproj +++ b/OptimizelySDK.Tests/OptimizelySDK.Tests.csproj @@ -97,6 +97,7 @@ + diff --git a/OptimizelySDK.Tests/TestSetup.cs b/OptimizelySDK.Tests/TestSetup.cs new file mode 100644 index 00000000..5f77494c --- /dev/null +++ b/OptimizelySDK.Tests/TestSetup.cs @@ -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 + } + } +} diff --git a/OptimizelySDK/OptimizelyUserContext.cs b/OptimizelySDK/OptimizelyUserContext.cs index aca35788..5c6f97cb 100644 --- a/OptimizelySDK/OptimizelyUserContext.cs +++ b/OptimizelySDK/OptimizelyUserContext.cs @@ -52,7 +52,7 @@ public OptimizelyUserContext(Optimizely optimizely, string userId, UserAttribute /// Returns Optimizely instance associated with the UserContext. /// /// Optimizely instance. - public Optimizely GetOptimizely() + public virtual Optimizely GetOptimizely() { return Optimizely; } @@ -61,7 +61,7 @@ public Optimizely GetOptimizely() /// Returns UserId associated with the UserContext /// /// UserId of this instance. - public string GetUserId() + public virtual string GetUserId() { return UserId; } @@ -108,7 +108,7 @@ public void SetAttribute(string key, object value) /// /// A flag key for which a decision will be made. /// A decision result. - public OptimizelyDecision Decide(string key) + public virtual OptimizelyDecision Decide(string key) { return Decide(key, new OptimizelyDecideOption[] { }); } @@ -122,7 +122,7 @@ public OptimizelyDecision Decide(string key) /// A flag key for which a decision will be made. /// A list of options for decision-making. /// A decision result. - public OptimizelyDecision Decide(string key, + public virtual OptimizelyDecision Decide(string key, OptimizelyDecideOption[] options) { var optimizelyUserContext = Copy(); @@ -134,7 +134,7 @@ public OptimizelyDecision Decide(string key, /// /// list of flag keys for which a decision will be made. /// A dictionary of all decision results, mapped by flag keys. - public Dictionary DecideForKeys(string[] keys, OptimizelyDecideOption[] options) + public virtual Dictionary DecideForKeys(string[] keys, OptimizelyDecideOption[] options) { var optimizelyUserContext = Copy(); return Optimizely.DecideForKeys(optimizelyUserContext, keys, options); @@ -145,7 +145,7 @@ public Dictionary DecideForKeys(string[] keys, Optim /// /// list of flag keys for which a decision will be made. /// A dictionary of all decision results, mapped by flag keys. - public Dictionary DecideForKeys(string[] keys) + public virtual Dictionary DecideForKeys(string[] keys) { return DecideForKeys(keys, new OptimizelyDecideOption[] { }); } @@ -154,7 +154,7 @@ public Dictionary DecideForKeys(string[] keys) /// Returns a key-map of decision results ({@link OptimizelyDecision}) for all active flag keys. /// /// A dictionary of all decision results, mapped by flag keys. - public Dictionary DecideAll() + public virtual Dictionary DecideAll() { return DecideAll(new OptimizelyDecideOption[] { }); } @@ -164,7 +164,7 @@ public Dictionary DecideAll() /// /// A list of options for decision-making. /// All decision results mapped by flag keys. - public Dictionary DecideAll(OptimizelyDecideOption[] options) + public virtual Dictionary DecideAll(OptimizelyDecideOption[] options) { var optimizelyUserContext = Copy(); return Optimizely.DecideAll(optimizelyUserContext, options); @@ -174,7 +174,7 @@ public Dictionary DecideAll(OptimizelyDecideOption[] /// Track an event. /// /// The event name. - public void TrackEvent(string eventName) + public virtual void TrackEvent(string eventName) { TrackEvent(eventName, new EventTags()); } @@ -184,7 +184,7 @@ public void TrackEvent(string eventName) /// /// The event name. /// A map of event tag names to event tag values. - public void TrackEvent(string eventName, + public virtual void TrackEvent(string eventName, EventTags eventTags) { Optimizely.Track(eventName, UserId, Attributes, eventTags);