Skip to content

Whitelisted bucketing logic is in DecisionService #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2018
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
24 changes: 0 additions & 24 deletions OptimizelySDK.Tests/BucketerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,30 +165,6 @@ public void TestBucketInvalidExperiment()
LoggerMock.Verify(l => l.Log(It.IsAny<LogLevel>(), It.IsAny<string>()), Times.Never);
}

[Test]
public void TestBucketValidExperimentNotInGroupUserInForcedVariation()
{
var bucketer = new Bucketer(LoggerMock.Object);

Assert.AreEqual(new Variation { Id = "7722370027", Key = "control" },
bucketer.Bucket(Config, Config.GetExperimentFromKey("test_experiment"), TestBucketingIdControl, "user1"));

LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [user1] is forced into variation [control]."));
LoggerMock.Verify(l => l.Log(It.IsAny<LogLevel>(), It.IsAny<string>()), Times.Exactly(1));
}

[Test]
public void TestBucketValidExperimentInGroupUserInForcedVariation()
{
var bucketer = new Bucketer(LoggerMock.Object);

Assert.AreEqual(new Variation { Id = "7722260071", Key = "group_exp_1_var_1" },
bucketer.Bucket(Config, Config.GetExperimentFromKey("group_experiment_1"), TestBucketingIdControl, "user1"));

LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [user1] is forced into variation [group_exp_1_var_1]."));
LoggerMock.Verify(l => l.Log(It.IsAny<LogLevel>(), It.IsAny<string>()), Times.Exactly(1));
}

[Test]
public void TestBucketWithBucketingId()
{
Expand Down
14 changes: 0 additions & 14 deletions OptimizelySDK/Bucketing/Bucketer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,6 @@ public virtual Variation Bucket(ProjectConfig config, Experiment experiment, str
if (string.IsNullOrEmpty(experiment.Key))
return new Variation();

// Check if user is whitelisted for a variation.
var forcedVariations = experiment.ForcedVariations;
if (forcedVariations != null && forcedVariations.ContainsKey(userId))
{
string variationKey = forcedVariations[userId];
variation = config.GetVariationFromKey(experiment.Key, variationKey);
if (!string.IsNullOrEmpty(variationKey))
{
message = string.Format("User [{0}] is forced into variation [{1}].", userId, variationKey);
Logger.Log(LogLevel.INFO, message);
}
return variation;
}

// Determine if experiment is in a mutually exclusive group.
if (experiment.IsInMutexGroup)
{
Expand Down