-
Notifications
You must be signed in to change notification settings - Fork 20
feat(ForcedDecisions): add forced-decisions APIs to OptimizelyUserContext #285
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
Changes from 1 commit
e9f3ad3
482628c
97acb39
c097e89
d23fcd0
3abb3e5
dd50814
973f24d
4747186
3b3070c
68d918e
30a808b
14a7288
8c289b6
6917f4d
9723d7a
86a099b
d5583d7
b7b8fb7
a46516e
b62c547
7df6dd0
d1e8e68
965c6bf
63e86b7
44229f0
99c1769
77626e0
5287e54
147773e
d418ea2
13ca784
aefdf34
58d40bf
484dc21
7d420c4
e89f4a0
ac5fd97
7570f48
a01050b
9efc42a
9da8ee5
4783824
8fa3198
5eb9922
0381512
874157e
f3ec5fb
a139aa9
ba19e30
9e4409d
044ad4a
a073b79
a401aa9
1106c44
692ee26
cbbe452
19eb3da
e72faee
97b52a9
7b76612
5288bb1
4323773
86f8ea5
8240f6e
82a8d93
87a1fc3
af39695
2500dd7
8b32b39
b209680
758f5d0
01a90ca
7ea219e
9e17cd8
03002e2
f4e348b
a061f72
4427c9f
0838c14
6793b0b
0211a2d
5ff593e
8ef2a93
85ca51d
5edcc18
a18f774
c9db119
c9acbdb
964bba5
d78a22b
3bd0991
b685bbd
87fe232
059fafd
80abfa3
9c87d71
f0f8ee8
9afc59a
e4c190c
07b69f2
9e427fa
1a3aab3
8000
3bd0bb0
ba225f9
6f563bb
c7312ec
0db66fd
8bce727
69a2f51
10eaf22
f608a70
d5c621b
5511a91
375d748
5be1a05
48b15ef
4bca717
0b669eb
6478ed6
d359a0f
cdf53de
b6170cd
0d46ef7
de95a2c
0063e26
2fc7a47
85b00ff
0dccc30
a829f60
e43898f
0ac3dbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using NUnit.Framework; | ||
using OptimizelySDK.Entity; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is very critical, I will recommend to split into two parts, one is the util and the other one is the testing of this class with hardcoded expected and actual values. |
||
using OptimizelySDK.OptimizelyDecisions; | ||
using OptimizelySDK.OptlyConfig; | ||
using System; | ||
using System.Collections.Generic; | ||
|
@@ -599,5 +600,24 @@ public static void AreEqual(TrafficAllocation expected, TrafficAllocation actual | |
} | ||
|
||
#endregion TrafficAllocation | ||
|
||
#region DecisionReasons | ||
|
||
public static void AreEqual(DecisionReasons expected, DecisionReasons actual) | ||
{ | ||
AreEquivalent(expected.ToReport(), actual.ToReport()); | ||
} | ||
|
||
#endregion DecisionReasons | ||
|
||
#region Result T | ||
|
||
public static void AreEqual(Result<Variation> expected, Result<Variation> actual) | ||
{ | ||
AreEqual(expected.DecisionReasons, actual.DecisionReasons); | ||
AreEqual(expected.ResultObject, actual.ResultObject); | ||
} | ||
|
||
#endregion Result T | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,21 @@ public void FindForcedDecisionReturnsValueWithRuleKey() | |
Assert.AreEqual("variation", result); | ||
} | ||
|
||
[Test] | ||
public void FindValidatedForcedDecisionReturnsCorrectDecision() | ||
{ | ||
var decisionReasons = new DecisionReasons(); | ||
decisionReasons.AddInfo("{0}", "Variation variation is mapped to flag: flagKey and rule: rule in the forced decision map."); | ||
var expectedResult = Result<Variation>.NewResult(new Variation { }, decisionReasons); | ||
var user = Optimizely.CreateUserContext(UserID); | ||
|
||
user.SetForcedDecision("flagKey", "rule", "variation"); | ||
|
||
var result = user.FindValidatedForcedDecision("flagKey", "rule"); | ||
|
||
Assertions.AreEqual(expectedResult, result); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need the same test for "invalid" variationKey as well. |
||
|
||
[Test] | ||
public void RemoveForcedDecisionReturnsFalseForNullFlagKey() | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.