Exemplo n.º 1
0
        public void EnqueueMessagePollForMessageTest()
        {
            string        queueName = Guid.NewGuid().ToString();
            KMeansJobData message   = new KMeansJobData(Guid.NewGuid(), 1, null, 2, 10, DateTime.Now);
            bool          async     = false;

            AzureHelper.EnqueueMessage(queueName, message, async);

            KMeansJobData foundMessage = null;

            AzureHelper.ExponentialBackoff(() =>
                                           AzureHelper.PollForMessage <KMeansJobData>(queueName, msg =>
            {
                foundMessage = msg;
                return(true);
            }),
                                           firstDelayMilliseconds: 100,
                                           backoffFactor: 2,
                                           maxDelay: 1000,
                                           retryLimit: 5
                                           );

            Assert.AreNotEqual(null, foundMessage);

            Assert.AreEqual(message.JobID, foundMessage.JobID);
            Assert.AreEqual(message.K, foundMessage.K);
        }