Esempio n. 1
0
        public void testFailedItemsEnqueuedAgain()
        {
            var          q = new PersistentBlockingQueue(new MockStorage(), new PayloadToJsonString());
            AsyncEmitter e = new AsyncEmitter(new MockEndpoint()
            {
                Response = false
            }, q);

            // no events will send, and so they should be at the start of the queue

            e.Start();

            var p = new Payload();

            p.AddDict(new Dictionary <string, string>()
            {
                { "foo", "bar" }
            });

            e.Input(p);
            Thread.Sleep(100); // this could be done better with triggers of some kind
            e.Stop();

            var inQueue = q.Peek(1);

            Assert.AreEqual(1, inQueue.Count);
        }
Esempio n. 2
0
        public void testBackoffInterval()
        {
            // because of the back off period (5sec +), this event should only be sent once
            var q            = new PersistentBlockingQueue(new MockStorage(), new PayloadToJsonString());
            var mockEndpoint = new MockEndpoint()
            {
                Response = false
            };
            AsyncEmitter e = new AsyncEmitter(mockEndpoint, q);

            e.Start();
            var p = new Payload();

            p.AddDict(new Dictionary <string, string>()
            {
                { "foo", "bar" }
            });
            e.Input(p);
            Thread.Sleep(100);
            e.Stop();

            Assert.AreEqual(1, mockEndpoint.CallCount);
        }