@@ -1016,6 +1016,297 @@ public void TestConversionEventWithNumericTag()
1016
1016
Assert . IsTrue ( TestData . CompareObjects ( expectedEvent , logEvent ) ) ;
1017
1017
}
1018
1018
1019
+ [ Test ]
1020
+ public void TestConversionEventWithFalsyNumericAndRevenueValues ( )
1021
+ {
1022
+ var guid = Guid . NewGuid ( ) ;
1023
+ var timeStamp = TestData . SecondsSince1970 ( ) ;
1024
+ var payloadParams = new Dictionary < string , object >
1025
+ {
1026
+ { "visitors" , new object [ ]
1027
+ {
1028
+ new Dictionary < string , object > ( )
1029
+ {
1030
+ { "snapshots" , new object [ ]
1031
+ {
1032
+ new Dictionary < string , object >
1033
+ {
1034
+ { "decisions" , new object [ ]
1035
+ {
1036
+ new Dictionary < string , object >
1037
+ {
1038
+ { "campaign_id" , "7719770039" } ,
1039
+ { "experiment_id" , "7716830082" } ,
1040
+ { "variation_id" , "7722370027" }
1041
+ }
1042
+ }
1043
+ } ,
1044
+ { "events" , new object [ ]
1045
+ {
1046
+ new Dictionary < string , object >
1047
+ {
1048
+ { "entity_id" , "7718020063" } ,
1049
+ { "timestamp" , timeStamp } ,
1050
+ { "uuid" , guid } ,
1051
+ { "key" , "purchase" } ,
1052
+ { "revenue" , 0 } ,
1053
+ { "value" , 0.0 } ,
1054
+ { "tags" ,
1055
+ new Dictionary < string , object >
1056
+ {
1057
+ { "revenue" , 0 } ,
1058
+ { "value" , 0.0 }
1059
+ }
1060
+ }
1061
+ }
1062
+ }
1063
+ }
1064
+ }
1065
+ }
1066
+ } ,
1067
+ { "attributes" , new object [ ]
1068
+ {
1069
+ new Dictionary < string , object >
1070
+ {
1071
+ { "entity_id" , ControlAttributes . BOT_FILTERING_ATTRIBUTE } ,
1072
+ { "key" , ControlAttributes . BOT_FILTERING_ATTRIBUTE } ,
1073
+ { "type" , "custom" } ,
1074
+ { "value" , true }
1075
+ }
1076
+ }
1077
+ } ,
1078
+ { "visitor_id" , TestUserId }
1079
+ }
1080
+ }
1081
+ } ,
1082
+ { "project_id" , "7720880029" } ,
1083
+ { "account_id" , "1592310167" } ,
1084
+ { "client_name" , "csharp-sdk" } ,
1085
+ { "client_version" , Optimizely . SDK_VERSION } ,
1086
+ { "revision" , "15" } ,
1087
+ { "anonymize_ip" , false }
1088
+ } ;
1089
+
1090
+ var expectedEvent = new LogEvent (
1091
+ "https://logx.optimizely.com/v1/events" ,
1092
+ payloadParams ,
1093
+ "POST" ,
1094
+ new Dictionary < string , string >
1095
+ {
1096
+ { "Content-Type" , "application/json" }
1097
+ } ) ;
1098
+
1099
+ var experimentToVariationMap = new Dictionary < string , Variation >
1100
+ {
1101
+ { "7716830082" , new Variation { Id = "7722370027" , Key = "control" } }
1102
+ } ;
1103
+
1104
+ var logEvent = EventBuilder . CreateConversionEvent ( Config , "purchase" , experimentToVariationMap , TestUserId , null ,
1105
+ new EventTags
1106
+ {
1107
+ { "revenue" , 0 } ,
1108
+ { "value" , 0.0 }
1109
+ } ) ;
1110
+
1111
+ TestData . ChangeGUIDAndTimeStamp ( logEvent . Params , timeStamp , guid ) ;
1112
+
1113
+ Assert . IsTrue ( TestData . CompareObjects ( expectedEvent , logEvent ) ) ;
1114
+ }
1115
+
1116
+ [ Test ]
1117
+ public void TestConversionEventWithNumericValue1 ( )
1118
+ {
1119
+ var guid = Guid . NewGuid ( ) ;
1120
+ var timeStamp = TestData . SecondsSince1970 ( ) ;
1121
+ var payloadParams = new Dictionary < string , object >
1122
+ {
1123
+ { "visitors" , new object [ ]
1124
+ {
1125
+ new Dictionary < string , object > ( )
1126
+ {
1127
+ { "snapshots" , new object [ ]
1128
+ {
1129
+ new Dictionary < string , object >
1130
+ {
1131
+ { "decisions" , new object [ ]
1132
+ {
1133
+ new Dictionary < string , object >
1134
+ {
1135
+ { "campaign_id" , "7719770039" } ,
1136
+ { "experiment_id" , "7716830082" } ,
1137
+ { "variation_id" , "7722370027" }
1138
+ }
1139
+ }
1140
+ } ,
1141
+ { "events" , new object [ ]
1142
+ {
1143
+ new Dictionary < string , object >
1144
+ {
1145
+ { "entity_id" , "7718020063" } ,
1146
+ { "timestamp" , timeStamp } ,
1147
+ { "uuid" , guid } ,
1148
+ { "key" , "purchase" } ,
1149
+ { "revenue" , 10 } ,
1150
+ { "value" , 1.0 } ,
1151
+ { "tags" ,
1152
+ new Dictionary < string , object >
1153
+ {
1154
+ { "revenue" , 10 } ,
1155
+ { "value" , 1.0 }
1156
+ }
1157
+ }
1158
+ }
1159
+ }
1160
+ }
1161
+ }
1162
+ }
1163
+ } ,
1164
+ { "attributes" , new object [ ]
1165
+ {
1166
+ new Dictionary < string , object >
1167
+ {
1168
+ { "entity_id" , ControlAttributes . BOT_FILTERING_ATTRIBUTE } ,
1169
+ { "key" , ControlAttributes . BOT_FILTERING_ATTRIBUTE } ,
1170
+ { "type" , "custom" } ,
1171
+ { "value" , true }
1172
+ }
1173
+ }
1174
+ } ,
1175
+ { "visitor_id" , TestUserId }
1176
+ }
1177
+ }
1178
+ } ,
1179
+ { "project_id" , "7720880029" } ,
1180
+ { "account_id" , "1592310167" } ,
1181
+ { "client_name" , "csharp-sdk" } ,
1182
+ { "client_version" , Optimizely . SDK_VERSION } ,
1183
+ { "revision" , "15" } ,
1184
+ { "anonymize_ip" , false }
1185
+ } ;
1186
+
1187
+ var expectedEvent = new LogEvent (
1188
+ "https://logx.optimizely.com/v1/events" ,
1189
+ payloadParams ,
1190
+ "POST" ,
1191
+ new Dictionary < string , string >
1192
+ {
1193
+ { "Content-Type" , "application/json" }
1194
+ } ) ;
1195
+
1196
+ var experimentToVariationMap = new Dictionary < string , Variation >
1197
+ {
1198
+ { "7716830082" , new Variation { Id = "7722370027" , Key = "control" } }
1199
+ } ;
1200
+
1201
+ var logEvent = EventBuilder . CreateConversionEvent ( Config , "purchase" , experimentToVariationMap , TestUserId , null ,
1202
+ new EventTags
1203
+ {
1204
+ { "revenue" , 10 } ,
1205
+ { "value" , 1.0 }
1206
+ } ) ;
1207
+
1208
+ TestData . ChangeGUIDAndTimeStamp ( logEvent . Params , timeStamp , guid ) ;
1209
+
1210
+ Assert . IsTrue ( TestData . CompareObjects ( expectedEvent , logEvent ) ) ;
1211
+ }
1212
+ [ Test ]
1213
+ public void TestConversionEventWithRevenueValue1 ( )
1214
+ {
1215
+ var guid = Guid . NewGuid ( ) ;
1216
+ var timeStamp = TestData . SecondsSince1970 ( ) ;
1217
+ var payloadParams = new Dictionary < string , object >
1218
+ {
1219
+ { "visitors" , new object [ ]
1220
+ {
1221
+ new Dictionary < string , object > ( )
1222
+ {
1223
+ { "snapshots" , new object [ ]
1224
+ {
1225
+ new Dictionary < string , object >
1226
+ {
1227
+ { "decisions" , new object [ ]
1228
+ {
1229
+ new Dictionary < string , object >
1230
+ {
1231
+ { "campaign_id" , "7719770039" } ,
1232
+ { "experiment_id" , "7716830082" } ,
1233
+ { "variation_id" , "7722370027" }
1234
+ }
1235
+ }
1236
+ } ,
1237
+ { "events" , new object [ ]
1238
+ {
1239
+ new Dictionary < string , object >
1240
+ {
1241
+ { "entity_id" , "7718020063" } ,
1242
+ { "timestamp" , timeStamp } ,
1243
+ { "uuid" , guid } ,
1244
+ { "key" , "purchase" } ,
1245
+ { "revenue" , 1 } ,
1246
+ { "value" , 10.0 } ,
1247
+ { "tags" ,
1248
+ new Dictionary < string , object >
1249
+ {
1250
+ { "revenue" , 1 } ,
1251
+ { "value" , 10.0 }
1252
+ }
1253
+ }
1254
+ }
1255
+ }
1256
+ }
1257
+ }
1258
+ }
1259
+ } ,
1260
+ { "attributes" , new object [ ]
1261
+ {
1262
+ new Dictionary < string , object >
1263
+ {
1264
+ { "entity_id" , ControlAttributes . BOT_FILTERING_ATTRIBUTE } ,
1265
+ { "key" , ControlAttributes . BOT_FILTERING_ATTRIBUTE } ,
1266
+ { "type" , "custom" } ,
1267
+ { "value" , true }
1268
+ }
1269
+ }
1270
+ } ,
1271
+ { "visitor_id" , TestUserId }
1272
+ }
1273
+ }
1274
+ } ,
1275
+ { "project_id" , "7720880029" } ,
1276
+ { "account_id" , "1592310167" } ,
1277
+ { "client_name" , "csharp-sdk" } ,
1278
+ { "client_version" , Optimizely . SDK_VERSION } ,
1279
+ { "revision" , "15" } ,
1280
+ { "anonymize_ip" , false }
1281
+ } ;
1282
+
1283
+ var expectedEvent = new LogEvent (
1284
+ "https://logx.optimizely.com/v1/events" ,
1285
+ payloadParams ,
1286
+ "POST" ,
1287
+ new Dictionary < string , string >
1288
+ {
1289
+ { "Content-Type" , "application/json" }
1290
+ } ) ;
1291
+
1292
+ var experimentToVariationMap = new Dictionary < string , Variation >
1293
+ {
1294
+ { "7716830082" , new Variation { Id = "7722370027" , Key = "control" } }
1295
+ } ;
1296
+
1297
+ var logEvent = EventBuilder . CreateConversionEvent ( Config , "purchase" , experimentToVariationMap , TestUserId , null ,
1298
+ new EventTags
1299
+ {
1300
+ { "revenue" , 1 } ,
1301
+ { "value" , 10.0 }
1302
+ } ) ;
1303
+
1304
+ TestData . ChangeGUIDAndTimeStamp ( logEvent . Params , timeStamp , guid ) ;
1305
+
1306
+ Assert . IsTrue ( TestData . CompareObjects ( expectedEvent , logEvent ) ) ;
1307
+ }
1308
+
1309
+
1019
1310
[ Test ]
1020
1311
public void TestCreateConversionEventWithBucketingIDAttribute ( )
1021
1312
{
0 commit comments