@@ -32,6 +32,7 @@ public class EventBuilderTest
32
32
{
33
33
private string TestUserId = string . Empty ;
34
34
private ProjectConfig Config ;
35
+
35
36
private EventBuilder EventBuilder ;
36
37
37
38
[ TestFixtureSetUp ]
@@ -83,7 +84,7 @@ public void TestCreateImpressionEventNoAttributes()
83
84
}
84
85
}
85
86
} ,
86
- { "attributes" , new object [ ]
87
+ { "attributes" , new object [ ]
87
88
{
88
89
new Dictionary < string , object >
89
90
{
@@ -107,7 +108,7 @@ public void TestCreateImpressionEventNoAttributes()
107
108
} ;
108
109
109
110
var expectedLogEvent = new LogEvent ( "https://logx.optimizely.com/v1/events" ,
110
- payloadParams ,
111
+ payloadParams ,
111
112
"POST" ,
112
113
new Dictionary < string , string >
113
114
{
@@ -191,10 +192,10 @@ public void TestCreateImpressionEventWithAttributes()
191
192
{ "revision" , "15" } ,
192
193
{ "anonymize_ip" , false }
193
194
} ;
194
-
195
+
195
196
var expectedLogEvent = new LogEvent ( "https://logx.optimizely.com/v1/events" ,
196
197
payloadParams ,
197
- "POST" ,
198
+ "POST" ,
198
199
new Dictionary < string , string >
199
200
{
200
201
{ "Content-Type" , "application/json" }
@@ -255,7 +256,7 @@ public void TestCreateConversionEventNoAttributesNoValue()
255
256
}
256
257
} ,
257
258
{ "visitor_id" , TestUserId } ,
258
- { "attributes" , new object [ ]
259
+ { "attributes" , new object [ ]
259
260
{
260
261
new Dictionary < string , object >
261
262
{
@@ -276,7 +277,7 @@ public void TestCreateConversionEventNoAttributesNoValue()
276
277
{ "revision" , "15" } ,
277
278
{ "anonymize_ip" , false }
278
279
} ;
279
-
280
+
280
281
var expectedEvent = new LogEvent (
281
282
"https://logx.optimizely.com/v1/events" ,
282
283
payloadParams ,
@@ -302,7 +303,7 @@ public void TestCreateConversionEventWithAttributesNoValue()
302
303
{
303
304
var guid = Guid . NewGuid ( ) ;
304
305
var timeStamp = TestData . SecondsSince1970 ( ) ;
305
-
306
+
306
307
var payloadParams = new Dictionary < string , object >
307
308
{
308
309
{ "visitors" , new object [ ]
@@ -597,7 +598,7 @@ public void TestCreateConversionEventWithAttributesWithValue()
597
598
598
599
Assert . IsTrue ( TestData . CompareObjects ( expectedEvent , logEvent ) ) ;
599
600
}
600
-
601
+
601
602
[ Test ]
602
603
public void TestCreateConversionEventNoAttributesWithInvalidValue ( )
603
604
{
@@ -668,7 +669,7 @@ public void TestCreateConversionEventNoAttributesWithInvalidValue()
668
669
{ "revision" , "15" } ,
669
670
{ "anonymize_ip" , false }
670
671
} ;
671
-
672
+
672
673
var expectedEvent = new LogEvent (
673
674
"https://logx.optimizely.com/v1/events" ,
674
675
payloadParams ,
@@ -989,7 +990,7 @@ public void TestCreateImpressionEventWithBucketingIDAttribute()
989
990
{ "company" , "Optimizely" } ,
990
991
{ ControlAttributes . BUCKETING_ID_ATTRIBUTE , "variation" }
991
992
} ;
992
-
993
+
993
994
var logEvent = EventBuilder . CreateImpressionEvent ( Config , Config . GetExperimentFromKey ( "test_experiment" ) , "7722370027" , TestUserId , userAttributes ) ;
994
995
995
996
TestData . ChangeGUIDAndTimeStamp ( logEvent . Params , timeStamp , guid ) ;
@@ -1362,5 +1363,139 @@ public void TestCreateConversionEventWhenBotFilteringIsNotProvidedInDatafile()
1362
1363
1363
1364
Assert . IsTrue ( TestData . CompareObjects ( expectedEvent , logEvent ) ) ;
1364
1365
}
1366
+
1367
+ [ Test ]
1368
+ public void TestCreateConversionEventWhenEventUsedInMultipleExp ( )
1369
+ {
1370
+ var guid = Guid . NewGuid ( ) ;
1371
+ var timeStamp = TestData . SecondsSince1970 ( ) ;
1372
+
1373
+ var eventInMultiExperimentConfig = ProjectConfig . Create ( TestData . SimpleABExperimentsDatafile , new NoOpLogger ( ) , new ErrorHandler . NoOpErrorHandler ( ) ) ;
1374
+
1375
+ var experimentIdVariationMap = new Dictionary < string , Variation >
1376
+ {
1377
+ {
1378
+ "111127" , new Variation { Id = "111129" , Key = "variation" }
1379
+ } ,
1380
+ {
1381
+ "111130" , new Variation { Id = "111131" , Key = "variation" }
1382
+ }
1383
+ } ;
1384
+
1385
+ var logEvent = EventBuilder . CreateConversionEvent ( eventInMultiExperimentConfig , "event_with_multiple_running_experiments" , experimentIdVariationMap , "test_user" ,
1386
+ new UserAttributes {
1387
+ { "test_attribute" , "test_value" }
1388
+ } ,
1389
+ new EventTags {
1390
+ { "revenue" , 4200 } ,
1391
+ { "value" , 1.234 } ,
1392
+ { "non-revenue" , "abc" }
1393
+ } ) ;
1394
+
1395
+ var payloadParams = new Dictionary < string , object >
1396
+ {
1397
+ { "client_version" , Optimizely . SDK_VERSION } ,
1398
+ { "project_id" , "111001" } ,
1399
+ //{"visitor_id", "test_user"},
1400
+ { "account_id" , "12001" } ,
1401
+ { "client_name" , "csharp-sdk" } ,
1402
+ { "anonymize_ip" , false } ,
1403
+ { "revision" , eventInMultiExperimentConfig . Revision } ,
1404
+ { "visitors" , new object [ ]
1405
+ {
1406
+ //visitors[0]
1407
+ new Dictionary < string , object >
1408
+ {
1409
+ //visitors[0].attributes
1410
+ {
1411
+ "attributes" , new object [ ]
1412
+ {
1413
+ new Dictionary < string , string >
1414
+ {
1415
+ { "entity_id" , "111094" } ,
1416
+ { "type" , "custom" } ,
1417
+ { "value" , "test_value" } ,
1418
+ { "key" , "test_attribute" }
1419
+ }
1420
+ }
1421
+ } ,
1422
+ //visitors[0].visitor_id
1423
+ { "visitor_id" , "test_user" } ,
1424
+ //visitors[0].snapshots
1425
+ { "snapshots" , new object [ ]
1426
+ {
1427
+ //snapshots[0]
1428
+ new Dictionary < string , object >
1429
+ {
1430
+ //snapshots[0].decisions
1431
+ { "decisions" , new object [ ]
1432
+ {
1433
+ //decisions[0]
1434
+ new Dictionary < string , object >
1435
+ {
1436
+ { "variation_id" , "111129" } ,
1437
+ { "experiment_id" , "111127" } ,
1438
+ { "campaign_id" , "111182" }
1439
+
1440
+ } ,
1441
+ //decisions[1]
1442
+ new Dictionary < string , object >
1443
+ {
1444
+ { "experiment_id" , "111130" } ,
1445
+ { "variation_id" , "111131" } ,
1446
+ { "campaign_id" , "111182" }
1447
+ }
1448
+ }
1449
+ } ,
1450
+ //snapshots[0].events
1451
+ {
1452
+ "events" , new object [ ]
1453
+ {
1454
+ new Dictionary < string , object >
1455
+ {
1456
+ { "uuid" , guid } ,
1457
+ { "timestamp" , timeStamp } ,
1458
+ { "revenue" , 4200 } ,
1459
+ { "value" , 1.234 } ,
1460
+ { "key" , "event_with_multiple_running_experiments" } ,
1461
+ { "entity_id" , "111095" } ,
1462
+ {
1463
+ "tags" , new Dictionary < string , object >
1464
+ {
1465
+ { "non-revenue" , "abc" } ,
1466
+ { "revenue" , 4200 } ,
1467
+ { "value" , 1.234 } ,
1468
+ }
1469
+ }
1470
+
1471
+ }
1472
+ }
1473
+ }
1474
+
1475
+ }
1476
+
1477
+ }
1478
+ }
1479
+
1480
+ }
1481
+ }
1482
+
1483
+ }
1484
+ } ;
1485
+
1486
+
1487
+ var expectedLogEvent = new LogEvent (
1488
+ "https://logx.optimizely.com/v1/events" ,
1489
+ payloadParams ,
1490
+ "POST" ,
1491
+ new Dictionary < string , string >
1492
+ {
1493
+ { "Content-Type" , "application/json" }
1494
+ } ) ;
1495
+
1496
+ TestData . ChangeGUIDAndTimeStamp ( logEvent . Params , timeStamp , guid ) ;
1497
+
1498
+ Assert . IsTrue ( TestData . CompareObjects ( expectedLogEvent , logEvent ) ) ;
1499
+ }
1365
1500
}
1366
1501
}
0 commit comments