Skip to content

Commit 00af331

Browse files
msohailhussainMichael Ng
authored andcommitted
feat(eventfactory): Event Factory and UserEventFactory (#174)
1 parent cfd4d77 commit 00af331

18 files changed

+2824
-38
lines changed

OptimizelySDK.Net35/OptimizelySDK.Net35.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@
180180
</Compile>
181181
<Compile Include="..\OptimizelySDK\Utils\DecisionInfoTypes.cs">
182182
<Link>Utils\DecisionInfoTypes.cs</Link>
183+
</Compile>
184+
<Compile Include="..\OptimizelySDK\Utils\DateTimeUtils.cs">
185+
<Link>Utils\DateTimeUtils.cs</Link>
183186
</Compile>
184187
<Compile Include="Properties\AssemblyInfo.cs" />
185188
<Compile Include="..\OptimizelySDK\Bucketing\Bucketer.cs">
@@ -257,6 +260,12 @@
257260
<Compile Include="..\OptimizelySDK\Event\Entity\VisitorAttribute.cs">
258261
<Link>Event\Entity\VisitorAttribute.cs</Link>
259262
</Compile>
263+
<Compile Include="..\OptimizelySDK\Event\EventFactory.cs">
264+
<Link>Event\EventFactory.cs</Link>
265+
</Compile>
266+
<Compile Include="..\OptimizelySDK\Event\UserEventFactory.cs">
267+
<Link>Event\UserEventFactory.cs</Link>
268+
</Compile>
260269
</ItemGroup>
261270
<ItemGroup>
262271
<None Include="..\OptimizelySDK\Utils\schema.json">

OptimizelySDK.Net40/OptimizelySDK.Net40.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@
181181
</Compile>
182182
<Compile Include="..\OptimizelySDK\Utils\DecisionInfoTypes.cs">
183183
<Link>Utils\DecisionInfoTypes.cs</Link>
184+
</Compile>
185+
<Compile Include="..\OptimizelySDK\Utils\DateTimeUtils.cs">
186+
<Link>Utils\DateTimeUtils.cs</Link>
184187
</Compile>
185188
<Compile Include="Properties\AssemblyInfo.cs" />
186189
<Compile Include="..\OptimizelySDK\Bucketing\Bucketer.cs">
@@ -267,6 +270,12 @@
267270
<Compile Include="..\OptimizelySDK\Event\Entity\VisitorAttribute.cs">
268271
<Link>Event\Entity\VisitorAttribute.cs</Link>
269272
</Compile>
273+
<Compile Include="..\OptimizelySDK\Event\EventFactory.cs">
274+
<Link>Event\EventFactory.cs</Link>
275+
</Compile>
276+
<Compile Include="..\OptimizelySDK\Event\UserEventFactory.cs">
277+
<Link>Event\UserEventFactory.cs</Link>
278+
</Compile>
270279
</ItemGroup>
271280
<ItemGroup>
272281
<None Include="..\OptimizelySDK\Utils\schema.json">

OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<Compile Include="..\OptimizelySDK\Utils\ConditionParser.cs" />
6363
<Compile Include="..\OptimizelySDK\Utils\AttributeMatchTypes.cs" />
6464
<Compile Include="..\OptimizelySDK\Utils\DecisionInfoTypes.cs" />
65+
<Compile Include="..\OptimizelySDK\Utils\DateTimeUtils.cs" />
6566
<Compile Include="..\OptimizelySDK\Bucketing\Bucketer.cs" />
6667
<Compile Include="..\OptimizelySDK\Bucketing\Decision.cs" />
6768
<Compile Include="..\OptimizelySDK\Bucketing\DecisionService.cs" />
@@ -109,6 +110,12 @@
109110
<Compile Include="..\OptimizelySDK\Event\Entity\Decision.cs">
110111
<Link>DecisionEvent.cs</Link>
111112
</Compile>
113+
<Compile Include="..\OptimizelySDK\Event\EventFactory.cs">
114+
<Link>EventFactory.cs</Link>
115+
</Compile>
116+
<Compile Include="..\OptimizelySDK\Event\UserEventFactory.cs">
117+
<Link>UserEventFactory.cs</Link>
118+
</Compile>
112119
</ItemGroup>
113120
<ItemGroup>
114121
<EmbeddedResource Include="..\OptimizelySDK\Utils\schema.json">

OptimizelySDK.Tests/EventTests/EventBuilderTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
using OptimizelySDK.Entity;
1818
using OptimizelySDK.Logger;
19-
using Moq;
2019
using OptimizelySDK.Event.Builder;
2120
using OptimizelySDK.Event;
2221
using System.Collections.Generic;

OptimizelySDK.Tests/EventTests/EventEntitiesTest.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,15 @@ public void TestImpressionEventEqualsSerializedPayload()
9595

9696
var visitorAttribute1 = new VisitorAttribute(entityId: "7723280020", type: "custom", value: "iPhone", key: "device_type");
9797
var visitorAttribute2 = new VisitorAttribute(entityId: ControlAttributes.BOT_FILTERING_ATTRIBUTE, type: "custom", value: true, key: ControlAttributes.BOT_FILTERING_ATTRIBUTE);
98-
var snapshotEvent = new SnapshotEvent(uuid: guid.ToString(), entityId: "7719770039", key: "campaign_activated",
99-
value: null, revenue: null, timestamp: timeStamp, eventTags: null);
98+
var snapshotEvent = new SnapshotEvent.Builder()
99+
.WithUUID(guid.ToString())
100+
.WithEntityId("7719770039")
101+
.WithKey("campaign_activated")
102+
.WithValue(null)
103+
.WithRevenue(null)
104+
.WithTimeStamp(timeStamp)
105+
.WithEventTags(null)
106+
.Build();
100107

101108
var decision = new Decision("7719770039", "7716830082", "77210100090");
102109
var snapshot = new Snapshot(events: new SnapshotEvent[] { snapshotEvent }, decisions: new Decision[] { decision });
@@ -204,13 +211,20 @@ public void TestConversionEventEqualsSerializedPayload()
204211

205212
var visitorAttribute = new VisitorAttribute(entityId: "111094", type: "custom", value: "test_value", key: "test_attribute");
206213

207-
var snapshotEvent = new SnapshotEvent(uuid: guid.ToString(), entityId: "111095", key: "event_with_multiple_running_experiments",
208-
value: (long?)1.234, revenue: 4200, timestamp: timeStamp, eventTags: new EventTags
214+
var snapshotEvent = new SnapshotEvent.Builder()
215+
.WithUUID(guid.ToString())
216+
.WithEntityId("111095")
217+
.WithKey("event_with_multiple_running_experiments")
218+
.WithValue((long?)1.234)
219+
.WithRevenue(4200)
220+
.WithTimeStamp(timeStamp)
221+
.WithEventTags(new EventTags
209222
{
210223
{"non-revenue", "abc"},
211224
{"revenue", 4200},
212225
{"value", 1.234}
213-
});
226+
})
227+
.Build();
214228

215229
var snapshot = new Snapshot(events: new SnapshotEvent[] { snapshotEvent });
216230

0 commit comments

Comments
 (0)