private void CheckCustomEvent(LdValue t, TestCustomEventProperties e, LdValue userJson) { Assert.Equal(LdValue.Of("custom"), t.Get("kind")); Assert.Equal(LdValue.Of(e.Key), t.Get("key")); Assert.Equal(e.Data, t.Get("data")); CheckEventUserOrKey(t, e.User, userJson); Assert.Equal(e.MetricValue.HasValue ? LdValue.Of(e.MetricValue.Value) : LdValue.Null, t.Get("metricValue")); }
private void RecordCustom(EventProcessor ep, TestCustomEventProperties e) { ep.RecordCustomEvent(new CustomEvent { Timestamp = e.Timestamp, User = e.User, EventKey = e.Key, Data = e.Data, MetricValue = e.MetricValue }); }
public void CustomEventIsQueuedWithUser() { var mockSender = MakeMockSender(); var captured = EventCapture.From(mockSender); using (var ep = MakeProcessor(_config, mockSender)) { var ce = new TestCustomEventProperties { Timestamp = _fixedTimestamp, User = _user, Key = "eventkey", Data = LdValue.Of(3), MetricValue = 1.5 }; RecordCustom(ep, ce); ep.Flush(); ep.WaitUntilInactive(); Assert.Collection(captured.Events, item => CheckIndexEvent(item, ce.Timestamp, _userJson), item => CheckCustomEvent(item, ce, LdValue.Null)); } }