Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions OptimizelySDK.Tests/ProjectConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,19 @@ public void TestTypeFieldParsedCorrectly()
Assert.AreEqual("fr", rolloutExperiment.Type);
}

[Test]
public void TestUnknownExperimentTypeAccepted()
{
var datafile = BuildFeatureRolloutDatafile(experimentType: "new_unknown_type");
var config = DatafileProjectConfig.Create(datafile, LoggerMock.Object,
ErrorHandlerMock.Object);

Assert.IsNotNull(config);
var experiment = config.GetExperimentFromKey("rollout_experiment");
Assert.IsNotNull(experiment);
Assert.AreEqual("new_unknown_type", experiment.Type);
}

#endregion
}
}
18 changes: 0 additions & 18 deletions OptimizelySDK/Config/DatafileProjectConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,26 +375,8 @@ private void Initialize()
}
}

var validExperimentTypes = new HashSet<string>
{
Experiment.EXPERIMENT_TYPE_AB,
Experiment.EXPERIMENT_TYPE_MAB,
Experiment.EXPERIMENT_TYPE_CMAB,
Experiment.EXPERIMENT_TYPE_TD,
Experiment.EXPERIMENT_TYPE_FR,
};

foreach (var experiment in _ExperimentIdMap.Values)
{
if (experiment.Type != null && !validExperimentTypes.Contains(experiment.Type))
{
Logger.Log(LogLevel.ERROR,
$@"Experiment ""{experiment.Key}"" has invalid type ""{experiment.Type}"".");
ErrorHandler.HandleError(
new InvalidExperimentException(
$"Invalid experiment type: {experiment.Type}"));
}

_VariationKeyMap[experiment.Key] = new Dictionary<string, Variation>();
_VariationIdMap[experiment.Key] = new Dictionary<string, Variation>();
_VariationIdMapByExperimentId[experiment.Id] = new Dictionary<string, Variation>();
Expand Down
4 changes: 0 additions & 4 deletions OptimizelySDK/Entity/Experiment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public class Experiment : ExperimentCore
{
private const string MUTEX_GROUP_POLICY = "random";

public const string EXPERIMENT_TYPE_AB = "ab";
public const string EXPERIMENT_TYPE_MAB = "mab";
public const string EXPERIMENT_TYPE_CMAB = "cmab";
public const string EXPERIMENT_TYPE_TD = "td";
public const string EXPERIMENT_TYPE_FR = "fr";

/// <summary>
Expand Down
Loading