Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }