예제 #1
0
        public void Queue()
        {
            var queue    = Substitute.For <IStorageQueue>();
            var poller   = new StorageQueuePoller <object>(queue);
            var returned = poller.Queue;

            Assert.AreEqual(queue, returned);
        }
예제 #2
0
        public void PollGetThrows()
        {
            var msg   = new CloudQueueMessage("data");
            var queue = Substitute.For <IStorageQueue>();

            queue.Get().ReturnsForAnyArgs <object>(x => { throw new ApplicationException(); });

            var poller = new StorageQueuePoller <object>(queue);

            Assert.That(() => poller.Poll(), Throws.TypeOf <ApplicationException>());
        }
예제 #3
0
        public async Task PollGetNull()
        {
            var queue = Substitute.For <IStorageQueue>();

            queue.Get().Returns(Task.FromResult <CloudQueueMessage>(null));

            var poller   = new StorageQueuePoller <object>(queue);
            var returned = await poller.Poll();

            Assert.IsNull(returned);

            await queue.Received().Get();
        }
예제 #4
0
        public async Task PollMany()
        {
            var msg  = new CloudQueueMessage("data");
            var msgs = new List <CloudQueueMessage>(3);

            msgs.Add(msg);
            msgs.Add(msg);
            msgs.Add(msg);

            var queue = Substitute.For <IStorageQueue>();

            queue.GetMany(3).Returns(Task.FromResult <IEnumerable <CloudQueueMessage> >(msgs));

            var poller   = new StorageQueuePoller <object>(queue);
            var returned = await poller.PollMany(3);

            Assert.IsNotNull(returned);
            Assert.AreEqual(3, returned.Count());

            await queue.Received().GetMany(3);
        }