Skip to content

Commit ecda765

Browse files
fix: tests & code under tests
1 parent 2ea917e commit ecda765

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

OptimizelySDK.Tests/OptimizelyUserContextTest.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void SetUp()
6161
Optimizely = new Optimizely(TestData.Datafile, EventDispatcherMock.Object,
6262
LoggerMock.Object, ErrorHandlerMock.Object);
6363
}
64-
64+
6565
private Mock<UserProfileService> MakeUserProfileServiceMock()
6666
{
6767
var projectConfig = DatafileProjectConfig.Create(TestData.Datafile, LoggerMock.Object,
@@ -440,7 +440,7 @@ public void SeparateDecideShouldHaveSameNumberOfUpsSaveAndLookup()
440440
{
441441
{ "224", new Decision("280") },
442442
{ "122238", new Decision("122240") },
443-
});
443+
});
444444
var flag2UserProfile = new UserProfile(UserID, new Dictionary<string, Decision>
445445
{
446446
{ "224", new Decision("280") },
@@ -531,7 +531,7 @@ public void DecideForKeysWithUpsShouldOnlyLookupSaveOnceWithMultipleFlags()
531531
Times.Once);
532532
Assert.AreEqual(saveArgsCollector.First(), expectedUserProfile.ToMap());
533533
}
534-
534+
535535
[Test]
536536
public void DecideForKeysWithOneFlag()
537537
{
@@ -561,11 +561,11 @@ public void DecideForKeysWithOneFlag()
561561
new string[0]);
562562
Assert.IsTrue(TestData.CompareObjects(decision, expDecision));
563563
}
564-
564+
565565
#endregion DecideForKeys
566-
566+
567567
#region DecideAll
568-
568+
569569
[Test]
570570
public void DecideAllWithUpsShouldOnlyLookupSaveOnce()
571571
{
@@ -595,8 +595,9 @@ public void DecideAllWithUpsShouldOnlyLookupSaveOnce()
595595
l => l.Log(LogLevel.ERROR, "The UserProfileService returned an invalid map."),
596596
Times.Never);
597597
userProfileServiceMock.Verify(l => l.Lookup(UserID), Times.Once);
598-
userProfileServiceMock.Verify(l => l.Save(It.IsAny<Dictionary<string,object>>()), Times.Once);
599-
Assert.AreEqual(saveArgsCollector.First(), expectedUserProfile.ToMap());
598+
userProfileServiceMock.Verify(l => l.Save(It.IsAny<Dictionary<string, object>>()),
599+
Times.Once);
600+
Assert.AreEqual(saveArgsCollector.First(), expectedUserProfile.ToMap());
600601
}
601602

602603
[Test]
@@ -806,7 +807,7 @@ public void DecideAllAllFlags()
806807
null,
807808
flagKey10,
808809
user,
809-
new string[0]);
810+
new[] { "Variable value for key \"any_key\" is invalid or wrong type." });
810811
Assert.IsTrue(TestData.CompareObjects(decisions[flagKey10], expDecision10));
811812
}
812813

OptimizelySDK/Optimizely.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,8 @@ ProjectConfig projectConfig
10401040
decisionSource = flagDecision.Source;
10411041
}
10421042

1043-
var reasonsToReport = decisionReasons.ToReport().ToArray();
1043+
var includeReasons= allOptions.Contains(OptimizelyDecideOption.INCLUDE_REASONS);
1044+
var reasonsToReport = decisionReasons.ToReport(includeReasons).ToArray();
10441045
var variationKey = flagDecision.Variation?.Key;
10451046
// TODO: add ruleKey values when available later. use a copy of experimentKey until then.
10461047
// add to event metadata as well (currently set to experimentKey)

0 commit comments

Comments
 (0)