Skip to content

Commit e0a1a41

Browse files
committed
feat(common): Changed public members on OptimizelyUserContext to be virtual
Make OptimizelyUserContext members virtual, making them overridable by testing frameworks
1 parent d2393e2 commit e0a1a41

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

OptimizelySDK/OptimizelyUserContext.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public OptimizelyUserContext(Optimizely optimizely, string userId, UserAttribute
5252
/// Returns Optimizely instance associated with the UserContext.
5353
/// </summary>
5454
/// <returns> Optimizely instance.</returns>
55-
public Optimizely GetOptimizely()
55+
public virtual Optimizely GetOptimizely()
5656
{
5757
return Optimizely;
5858
}
@@ -61,7 +61,7 @@ public Optimizely GetOptimizely()
6161
/// Returns UserId associated with the UserContext
6262
/// </summary>
6363
/// <returns>UserId of this instance.</returns>
64-
public string GetUserId()
64+
public virtual string GetUserId()
6565
{
6666
return UserId;
6767
}
@@ -108,7 +108,7 @@ public void SetAttribute(string key, object value)
108108
/// </summary>
109109
/// <param name="key">A flag key for which a decision will be made.</param>
110110
/// <returns>A decision result.</returns>
111-
public OptimizelyDecision Decide(string key)
111+
public virtual OptimizelyDecision Decide(string key)
112112
{
113113
return Decide(key, new OptimizelyDecideOption[] { });
114114
}
@@ -122,7 +122,7 @@ public OptimizelyDecision Decide(string key)
122122
/// <param name="key">A flag key for which a decision will be made.</param>
123123
/// <param name="options">A list of options for decision-making.</param>
124124
/// <returns>A decision result.</returns>
125-
public OptimizelyDecision Decide(string key,
125+
public virtual OptimizelyDecision Decide(string key,
126126
OptimizelyDecideOption[] options)
127127
{
128128
var optimizelyUserContext = Copy();
@@ -134,7 +134,7 @@ public OptimizelyDecision Decide(string key,
134134
/// </summary>
135135
/// <param name="keys">list of flag keys for which a decision will be made.</param>
136136
/// <returns>A dictionary of all decision results, mapped by flag keys.</returns>
137-
public Dictionary<string, OptimizelyDecision> DecideForKeys(string[] keys, OptimizelyDecideOption[] options)
137+
public virtual Dictionary<string, OptimizelyDecision> DecideForKeys(string[] keys, OptimizelyDecideOption[] options)
138138
{
139139
var optimizelyUserContext = Copy();
140140
return Optimizely.DecideForKeys(optimizelyUserContext, keys, options);
@@ -145,7 +145,7 @@ public Dictionary<string, OptimizelyDecision> DecideForKeys(string[] keys, Optim
145145
/// </summary>
146146
/// <param name="keys">list of flag keys for which a decision will be made.</param>
147147
/// <returns>A dictionary of all decision results, mapped by flag keys.</returns>
148-
public Dictionary<string, OptimizelyDecision> DecideForKeys(string[] keys)
148+
public virtual Dictionary<string, OptimizelyDecision> DecideForKeys(string[] keys)
149149
{
150150
return DecideForKeys(keys, new OptimizelyDecideOption[] { });
151151
}
@@ -154,7 +154,7 @@ public Dictionary<string, OptimizelyDecision> DecideForKeys(string[] keys)
154154
/// Returns a key-map of decision results ({@link OptimizelyDecision}) for all active flag keys.
155155
/// </summary>
156156
/// <returns>A dictionary of all decision results, mapped by flag keys.</returns>
157-
public Dictionary<string, OptimizelyDecision> DecideAll()
157+
public virtual Dictionary<string, OptimizelyDecision> DecideAll()
158158
{
159159
return DecideAll(new OptimizelyDecideOption[] { });
160160
}
@@ -164,7 +164,7 @@ public Dictionary<string, OptimizelyDecision> DecideAll()
164164
/// </summary>
165165
/// <param name="options">A list of options for decision-making.</param>
166166
/// <returns>All decision results mapped by flag keys.</returns>
167-
public Dictionary<string, OptimizelyDecision> DecideAll(OptimizelyDecideOption[] options)
167+
public virtual Dictionary<string, OptimizelyDecision> DecideAll(OptimizelyDecideOption[] options)
168168
{
169169
var optimizelyUserContext = Copy();
170170
return Optimizely.DecideAll(optimizelyUserContext, options);
@@ -174,7 +174,7 @@ public Dictionary<string, OptimizelyDecision> DecideAll(OptimizelyDecideOption[]
174174
/// Track an event.
175175
/// </summary>
176176
/// <param name="eventName">The event name.</param>
177-
public void TrackEvent(string eventName)
177+
public virtual void TrackEvent(string eventName)
178178
{
179179
TrackEvent(eventName, new EventTags());
180180
}
@@ -184,7 +184,7 @@ public void TrackEvent(string eventName)
184184
/// </summary>
185185
/// <param name="eventName">The event name.</param>
186186
/// <param name="eventTags">A map of event tag names to event tag values.</param>
187-
public void TrackEvent(string eventName,
187+
public virtual void TrackEvent(string eventName,
188188
EventTags eventTags)
189189
{
190190
Optimizely.Track(eventName, UserId, Attributes, eventTags);

0 commit comments

Comments
 (0)