public void UploadAsyncWithoutAwait() { var mParticle = new MockMParticle(new Configuration("apikey", "apiSecret")); var eventQueue = new UploadQueue((IMParticle)mParticle); eventQueue.AddEvent(new CustomEvent("0")); eventQueue.ForceUploadAsync(false); //since we did not await, the network request should not have complete yet Assert.Empty(mParticle.uploadedBatches); }
public async Task UploadAsyncWithAwait() { var mParticle = new MockMParticle(new Configuration("apikey", "apiSecret")); var eventQueue = new UploadQueue((IMParticle)mParticle); eventQueue.AddEvent(new CustomEvent("0")); await eventQueue.ForceUploadAsync(false); Assert.Single(mParticle.uploadedBatches); Assert.Single(mParticle.uploadedBatches[0].Events); var e = mParticle.uploadedBatches[0].Events[0]; Assert.Equal("0", ((CustomEvent)e).EventName); }
public void testBatchEventMaxLimit() { var mParticle = new MockMParticle(new Configuration("apikey", "apiSecret")); var eventQueue = new UploadQueue((IMParticle)mParticle); for (int i = 0; i < 200; i++) { var e = new CustomEvent(i + ""); eventQueue.AddEvent(e); } eventQueue.ForceUpload(false); Assert.Single(mParticle.uploadedBatches); Assert.Equal(100, mParticle.uploadedBatches[0].Events.Count); List <object> a = new List <object>(); a.Add(1); }
public void UploadsEventsInOrder() { var mParticle = new MockMParticle(new Configuration("apikey", "apiSecret")); var eventQueue = new UploadQueue((IMParticle)mParticle); for (int i = 1; i < 201; i++) { var e = new CustomEvent(i + ""); eventQueue.AddEvent(e); } eventQueue.ForceUpload(false); Assert.Single(mParticle.uploadedBatches); Assert.Equal(100, mParticle.uploadedBatches[0].Events.Count); foreach (BaseEvent e in mParticle.uploadedBatches[0].Events) { var eventNameNum = Int32.Parse(((CustomEvent)e).EventName); Assert.True(eventNameNum <= 100 && eventNameNum > 0); } }