Esempio n. 1
0
        public void MsgQueueInternalQueue_Basic()
        {
            InternalQueue queue = new InternalQueue("logical://Test");

            Assert.AreEqual("logical://Test", queue.Endpoint);

            // Verify that priority trumps enqueue order

            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.VeryLow, 0));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Low, 1));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 2));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.High, 3));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.VeryHigh, 4));
            Assert.AreEqual(5, queue.Count);

            Assert.AreEqual(4, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(3, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(2, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(1, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(0, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(0, queue.Count);

            // Verify that messages are dequeued in order of enqueuing
            // when the priorities are the same.

            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.VeryLow, 0));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.VeryLow, 1));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Low, 2));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Low, 3));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 4));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 5));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.High, 6));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.High, 7));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.VeryHigh, 8));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.VeryHigh, 9));
            Assert.AreEqual(10, queue.Count);

            Assert.AreEqual(8, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(9, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(6, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(7, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(4, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(5, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(2, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(3, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(0, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(1, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(0, queue.Count);

            // Verify that peek works

            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 0));
            Assert.AreEqual(1, queue.Count);
            Assert.AreEqual(0, queue.Peek(null).ProviderData);
            Assert.AreEqual(1, queue.Count);
            Assert.AreEqual(0, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(0, queue.Count);
        }
 public async Task EnqueueAsync(T item)
 {
     InternalQueue.Enqueue(item);
     Semaphore.Release();
 }
Esempio n. 3
0
        public void MsgQueueInternalQueue_Transactional()
        {
            InternalQueue   queue;
            BaseTransaction trans0 = new BaseTransaction(Stub.Param);
            BaseTransaction trans1 = new BaseTransaction(Stub.Param);

            // Verify that messages enqueued in a transaction are not
            // returned for other transactions.

            queue = new InternalQueue("logical://Test");
            queue.Enqueue(trans0, GetMsgInfo(DeliveryPriority.Normal, 0));
            queue.Enqueue(trans1, GetMsgInfo(DeliveryPriority.Normal, 1));
            queue.Enqueue(trans0, GetMsgInfo(DeliveryPriority.Normal, 2));
            queue.Enqueue(trans1, GetMsgInfo(DeliveryPriority.Normal, 3));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 4));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 5));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 6));

            Assert.AreEqual(4, queue.Dequeue(null).ProviderData);
            Assert.AreEqual(1, queue.Dequeue(trans1).ProviderData);
            Assert.AreEqual(0, queue.Dequeue(trans0).ProviderData);
            Assert.AreEqual(3, queue.Dequeue(trans1).ProviderData);
            Assert.AreEqual(2, queue.Dequeue(trans0).ProviderData);
            Assert.AreEqual(5, queue.Dequeue(trans1).ProviderData);
            Assert.AreEqual(6, queue.Dequeue(trans0).ProviderData);

            // Verify that Unlock() works.

            queue = new InternalQueue("logical://Test");
            queue.Enqueue(trans0, GetMsgInfo(DeliveryPriority.Normal, 0));
            queue.Enqueue(trans1, GetMsgInfo(DeliveryPriority.Normal, 1));
            queue.Enqueue(trans0, GetMsgInfo(DeliveryPriority.Normal, 2));
            queue.Enqueue(trans1, GetMsgInfo(DeliveryPriority.Normal, 3));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 4));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 5));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 6));
            queue.Unlock(trans0);
            queue.Unlock(trans1);

            for (int i = 0; i <= 6; i++)
            {
                Assert.AreEqual(i, queue.Dequeue(null).ProviderData);
            }

            // Verify that messages peeked from within a transaction
            // are not returned for other transactions.

            queue = new InternalQueue("logical://Test");
            queue.Enqueue(trans0, GetMsgInfo(DeliveryPriority.Normal, 0));
            queue.Enqueue(trans1, GetMsgInfo(DeliveryPriority.Normal, 1));
            queue.Enqueue(trans0, GetMsgInfo(DeliveryPriority.Normal, 2));
            queue.Enqueue(trans1, GetMsgInfo(DeliveryPriority.Normal, 3));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 4));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 5));
            queue.Enqueue(null, GetMsgInfo(DeliveryPriority.Normal, 6));
            queue.Unlock(trans0);
            queue.Unlock(trans1);

            Assert.AreEqual(0, queue.Peek(trans0).ProviderData);
            Assert.AreEqual(1, queue.Peek(trans1).ProviderData);
            Assert.AreEqual(0, queue.Peek(trans0).ProviderData);
            Assert.AreEqual(1, queue.Peek(trans1).ProviderData);

            Assert.AreEqual(2, queue.Peek(null).ProviderData);
            Assert.AreEqual(2, queue.Dequeue(null).ProviderData);

            Assert.AreEqual(0, queue.Dequeue(trans0).ProviderData);
            Assert.AreEqual(1, queue.Dequeue(trans1).ProviderData);
            Assert.AreEqual(3, queue.Dequeue(trans0).ProviderData);
            Assert.AreEqual(4, queue.Dequeue(trans1).ProviderData);
        }
Esempio n. 4
0
 private void WriteActivityState()
 {
     InternalQueue.Enqueue(WriteActivityStateInternal);
 }
Esempio n. 5
0
 private void WriteAttribution()
 {
     InternalQueue.Enqueue(WriteAttributionInternal);
 }
Esempio n. 6
0
 public void OpenUrl(Uri uri)
 {
     InternalQueue.Enqueue(() => OpenUrlInternal(uri));
 }
Esempio n. 7
0
 private void UpdateStatus()
 {
     InternalQueue.Enqueue(UpdateStatusInternal);
 }
Esempio n. 8
0
 public void TrackSubsessionStart()
 {
     InternalQueue.Enqueue(StartInternal);
 }
Esempio n. 9
0
 public void TrackSubsessionEnd()
 {
     InternalQueue.Enqueue(EndInternal);
 }
Esempio n. 10
0
 public void TrackEvent(AdjustEvent adjustEvent)
 {
     InternalQueue.Enqueue(() => TrackEventInternal(adjustEvent));
 }
Esempio n. 11
0
 public void SendNextPackage()
 {
     InternalQueue.Enqueue(SendNextInternal);
 }
Esempio n. 12
0
 public void SendFirstPackage()
 {
     InternalQueue.Enqueue(SendFirstInternal);
 }
Esempio n. 13
0
 public void AddPackage(ActivityPackage activityPackage)
 {
     InternalQueue.Enqueue(() => AddInternal(activityPackage));
 }
Esempio n. 14
0
 public void CheckAttribution(Dictionary <string, string> jsonDict)
 {
     InternalQueue.Enqueue(() => CheckAttributionInternal(jsonDict));
 }