@@ -51,7 +51,7 @@ public static Dictionary<string, object> CreateDictionary(string name, object en
51
51
public void TestInit ( )
52
52
{
53
53
// Check Version
54
- Assert . AreEqual ( 2 , Config . Version ) ;
54
+ Assert . AreEqual ( 4 , Config . Version ) ;
55
55
56
56
// Check Account ID
57
57
Assert . AreEqual ( "1592310167" , Config . AccountId ) ;
@@ -71,6 +71,10 @@ public void TestInit()
71
71
{
72
72
{ "test_experiment" , Config . GetExperimentFromKey ( "test_experiment" ) } ,
73
73
{ "paused_experiment" , Config . GetExperimentFromKey ( "paused_experiment" ) } ,
74
+ { "test_experiment_multivariate" , Config . GetExperimentFromKey ( "test_experiment_multivariate" ) } ,
75
+ { "test_experiment_with_feature_rollout" , Config . GetExperimentFromKey ( "test_experiment_with_feature_rollout" ) } ,
76
+ { "test_experiment_double_feature" , Config . GetExperimentFromKey ( "test_experiment_double_feature" ) } ,
77
+ { "test_experiment_integer_feature" , Config . GetExperimentFromKey ( "test_experiment_integer_feature" ) } ,
74
78
{ "group_experiment_1" , Config . GetExperimentFromKey ( "group_experiment_1" ) } ,
75
79
{ "group_experiment_2" , Config . GetExperimentFromKey ( "group_experiment_2" ) }
76
80
} ;
@@ -83,14 +87,17 @@ public void TestInit()
83
87
{
84
88
{ "7716830082" , Config . GetExperimentFromId ( "7716830082" ) } ,
85
89
{ "7716830585" , Config . GetExperimentFromId ( "7716830585" ) } ,
90
+ { "122230" , Config . GetExperimentFromId ( "122230" ) } ,
91
+ { "122235" , Config . GetExperimentFromId ( "122235" ) } ,
92
+ { "122238" , Config . GetExperimentFromId ( "122238" ) } ,
93
+ { "122241" , Config . GetExperimentFromId ( "122241" ) } ,
86
94
{ "7723330021" , Config . GetExperimentFromId ( "7723330021" ) } ,
87
95
{ "7718750065" , Config . GetExperimentFromId ( "7718750065" ) }
88
96
} ;
89
97
90
- Assert . IsTrue ( TestData . CompareObjects ( experimentIdMap , Config . ExperimentIdMap ) ) ;
91
-
92
- // Check Event key Map
98
+ Assert . IsTrue ( TestData . CompareObjects ( experimentIdMap , Config . ExperimentIdMap ) ) ;
93
99
100
+ // Check Event key Map
94
101
var eventKeyMap = new Dictionary < string , object > { { "purchase" , Config . GetEvent ( "purchase" ) } } ;
95
102
Assert . IsTrue ( TestData . CompareObjects ( eventKeyMap , Config . EventKeyMap ) ) ;
96
103
@@ -105,12 +112,13 @@ public void TestInit()
105
112
// Check Audience ID Map
106
113
var audienceIdMap = new Dictionary < string , object >
107
114
{
108
- { "7718080042" , Config . GetAudience ( "7718080042" ) }
115
+ { "7718080042" , Config . GetAudience ( "7718080042" ) } ,
116
+ { "11155" , Config . GetAudience ( "11155" ) }
109
117
} ;
110
118
Assert . IsTrue ( TestData . CompareObjects ( audienceIdMap , Config . AudienceIdMap ) ) ;
111
119
112
120
// Check Variation Key Map
113
- var variationKeyMap = new Dictionary < string , object >
121
+ var expectedVariationKeyMap = new Dictionary < string , object >
114
122
{
115
123
{ "test_experiment" , new Dictionary < string , object >
116
124
{
@@ -130,21 +138,44 @@ public void TestInit()
130
138
{ "group_exp_1_var_2" , Config . GetVariationFromKey ( "group_experiment_1" , "group_exp_1_var_2" ) }
131
139
}
132
140
} ,
133
- {
134
- "group_experiment_2" , new Dictionary < string , object >
141
+ { "group_experiment_2" , new Dictionary < string , object >
135
142
{
136
143
{ "group_exp_2_var_1" , Config . GetVariationFromKey ( "group_experiment_2" , "group_exp_2_var_1" ) } ,
137
144
{ "group_exp_2_var_2" , Config . GetVariationFromKey ( "group_experiment_2" , "group_exp_2_var_2" ) }
138
145
}
146
+ } ,
147
+ { "test_experiment_multivariate" , new Dictionary < string , object >
148
+ {
149
+ { "Fred" , Config . GetVariationFromKey ( "test_experiment_multivariate" , "Fred" ) } ,
150
+ { "Feorge" , Config . GetVariationFromKey ( "test_experiment_multivariate" , "Feorge" ) } ,
151
+ { "Gred" , Config . GetVariationFromKey ( "test_experiment_multivariate" , "Gred" ) } ,
152
+ { "George" , Config . GetVariationFromKey ( "test_experiment_multivariate" , "George" ) }
153
+ }
154
+ } ,
155
+ { "test_experiment_with_feature_rollout" , new Dictionary < string , object >
156
+ {
157
+ { "control" , Config . GetVariationFromKey ( "test_experiment_with_feature_rollout" , "control" ) } ,
158
+ { "variation" , Config . GetVariationFromKey ( "test_experiment_with_feature_rollout" , "variation" ) }
159
+ }
160
+ } ,
161
+ { "test_experiment_double_feature" , new Dictionary < string , object >
162
+ {
163
+ { "control" , Config . GetVariationFromKey ( "test_experiment_double_feature" , "control" ) } ,
164
+ { "variation" , Config . GetVariationFromKey ( "test_experiment_double_feature" , "variation" ) }
165
+ }
166
+ } ,
167
+ { "test_experiment_integer_feature" , new Dictionary < string , object >
168
+ {
169
+ { "control" , Config . GetVariationFromKey ( "test_experiment_integer_feature" , "control" ) } ,
170
+ { "variation" , Config . GetVariationFromKey ( "test_experiment_integer_feature" , "variation" ) }
171
+ }
139
172
}
140
173
} ;
141
174
142
-
143
-
144
- Assert . IsTrue ( TestData . CompareObjects ( variationKeyMap , Config . VariationKeyMap ) ) ;
175
+ Assert . IsTrue ( TestData . CompareObjects ( expectedVariationKeyMap , Config . VariationKeyMap ) ) ;
145
176
146
177
// Check Variation ID Map
147
- var variationIdMap = new Dictionary < string , object >
178
+ var expectedVariationIdMap = new Dictionary < string , object >
148
179
{
149
180
{ "test_experiment" , new Dictionary < string , object >
150
181
{
@@ -158,6 +189,32 @@ public void TestInit()
158
189
{ "7721010509" , Config . GetVariationFromId ( "paused_experiment" , "7721010509" ) }
159
190
}
160
191
} ,
192
+ { "test_experiment_multivariate" , new Dictionary < string , object >
193
+ {
194
+ { "122231" , Config . GetVariationFromId ( "test_experiment_multivariate" , "122231" ) } ,
195
+ { "122232" , Config . GetVariationFromId ( "test_experiment_multivariate" , "122232" ) } ,
196
+ { "122233" , Config . GetVariationFromId ( "test_experiment_multivariate" , "122233" ) } ,
197
+ { "122234" , Config . GetVariationFromId ( "test_experiment_multivariate" , "122234" ) }
198
+ }
199
+ } ,
200
+ { "test_experiment_with_feature_rollout" , new Dictionary < string , object >
201
+ {
202
+ { "122236" , Config . GetVariationFromId ( "test_experiment_with_feature_rollout" , "122236" ) } ,
203
+ { "122237" , Config . GetVariationFromId ( "test_experiment_with_feature_rollout" , "122237" ) }
204
+ }
205
+ } ,
206
+ { "test_experiment_double_feature" , new Dictionary < string , object >
207
+ {
208
+ { "122239" , Config . GetVariationFromId ( "test_experiment_double_feature" , "122239" ) } ,
209
+ { "122240" , Config . GetVariationFromId ( "test_experiment_double_feature" , "122240" ) }
210
+ }
211
+ } ,
212
+ { "test_experiment_integer_feature" , new Dictionary < string , object >
213
+ {
214
+ { "122242" , Config . GetVariationFromId ( "test_experiment_integer_feature" , "122242" ) } ,
215
+ { "122243" , Config . GetVariationFromId ( "test_experiment_integer_feature" , "122243" ) }
216
+ }
217
+ } ,
161
218
{ "group_experiment_1" , new Dictionary < string , object >
162
219
{
163
220
{ "7722260071" , Config . GetVariationFromId ( "group_experiment_1" , "7722260071" ) } ,
@@ -171,7 +228,45 @@ public void TestInit()
171
228
}
172
229
} ;
173
230
174
- Assert . IsTrue ( TestData . CompareObjects ( variationIdMap , Config . VariationIdMap ) ) ;
231
+ Assert . IsTrue ( TestData . CompareObjects ( expectedVariationIdMap , Config . VariationIdMap ) ) ;
232
+
233
+
234
+ // Check Variation returns correct variable usage
235
+ var featureVariableUsageInstance = new List < FeatureVariableUsage >
236
+ {
237
+ new FeatureVariableUsage { Id = "155560" , Value = "F" } ,
238
+ new FeatureVariableUsage { Id = "155561" , Value = "red" } ,
239
+ } ;
240
+ var expectedVariationUsage = new Variation { Id = "122231" , Key = "Fred" , FeatureVariableUsageInstances = featureVariableUsageInstance } ;
241
+
242
+ var actualVariationUsage = Config . GetVariationFromKey ( "test_experiment_multivariate" , "Fred" ) ;
243
+
244
+ Assert . IsTrue ( TestData . CompareObjects ( expectedVariationUsage , actualVariationUsage ) ) ;
245
+
246
+
247
+ // Check Feature Key map.
248
+ var expectedFeatureKeyMap = new Dictionary < string , FeatureFlag >
249
+ {
250
+ { "boolean_feature" , Config . GetFeatureFlagFromKey ( "boolean_feature" ) } ,
251
+ { "double_single_variable_feature" , Config . GetFeatureFlagFromKey ( "double_single_variable_feature" ) } ,
252
+ { "integer_single_variable_feature" , Config . GetFeatureFlagFromKey ( "integer_single_variable_feature" ) } ,
253
+ { "boolean_single_variable_feature" , Config . GetFeatureFlagFromKey ( "boolean_single_variable_feature" ) } ,
254
+ { "string_single_variable_feature" , Config . GetFeatureFlagFromKey ( "string_single_variable_feature" ) } ,
255
+ { "multi_variate_feature" , Config . GetFeatureFlagFromKey ( "multi_variate_feature" ) } ,
256
+ { "mutex_group_feature" , Config . GetFeatureFlagFromKey ( "mutex_group_feature" ) } ,
257
+ { "empty_feature" , Config . GetFeatureFlagFromKey ( "empty_feature" ) }
258
+ } ;
259
+
260
+ Assert . IsTrue ( TestData . CompareObjects ( expectedFeatureKeyMap , Config . FeatureKeyMap ) ) ;
261
+
262
+ // Check Feature Key map.
263
+ var expectedRolloutIdMap = new Dictionary < string , Rollout >
264
+ {
265
+ { "166660" , Config . GetRolloutFromId ( "166660" ) } ,
266
+ { "166661" , Config . GetRolloutFromId ( "166661" ) }
267
+ } ;
268
+
269
+ Assert . IsTrue ( TestData . CompareObjects ( expectedRolloutIdMap , Config . RolloutIdMap ) ) ;
175
270
}
176
271
177
272
[ Test ]
@@ -197,8 +292,6 @@ public void TestGetGroupValidId()
197
292
[ Test ]
198
293
public void TestGetGroupInvalidId ( )
199
294
{
200
-
201
-
202
295
var group = Config . GetGroup ( "invalid_id" ) ;
203
296
204
297
LoggerMock . Verify ( l => l . Log ( It . IsAny < LogLevel > ( ) , It . IsAny < string > ( ) ) , Times . Exactly ( 1 ) ) ;
0 commit comments