public void RetrieveForProcessing_ItemInQueue_DequeuesASingleItem()
        {
            var mocks = new LocatorMocks();
            var store = new ItemStore(mocks.MockLocator.Object);
            Guid id = Guid.NewGuid();
            byte[] expected = new UTF8Encoding().GetBytes("test data");
            mocks.MockQueueStore.Setup(q => q.Dequeue()).Returns(new ItemBase() { ResourceId = id });
            mocks.MockRawBlobStore.Setup(b => b.Retrieve(id)).Returns(expected);

            var actual = store.RetrieveForProcessing();

            mocks.MockRawBlobStore.Verify(b => b.Retrieve(id), Times.Once());
        }
        public void RetrieveForProcessing_NoItemInQueue_DoesNotAttemptToRetrieveDataFroBlobStore()
        {
            var mocks = new LocatorMocks();
            var store = new ItemStore(mocks.MockLocator.Object);
            Guid id = Guid.NewGuid();
            byte[] expected = new UTF8Encoding().GetBytes("test data");
            mocks.MockQueueStore.Setup(q => q.Dequeue()).Returns<ItemBase>(null);

            var actual = store.RetrieveForProcessing();

            mocks.MockRawBlobStore.Verify(b => b.Retrieve(It.IsAny<Guid>()), Times.Never());
        }
        public void RetrieveForProcessing_NoItemInQueue_ReturnsNull()
        {
            var mocks = new LocatorMocks();
            var store = new ItemStore(mocks.MockLocator.Object);
            Guid id = Guid.NewGuid();
            byte[] expected = new UTF8Encoding().GetBytes("test data");
            mocks.MockQueueStore.Setup(q => q.Dequeue()).Returns<ItemBase>(null);

            var actual = store.RetrieveForProcessing();

            Assert.IsNull(actual);
        }
        public void RetrieveForProcessing_ItemInQueue_ReturnsItemWithRawData()
        {
            var mocks = new LocatorMocks();
            var store = new ItemStore(mocks.MockLocator.Object);
            Guid id = Guid.NewGuid();
            byte[] expected = new UTF8Encoding().GetBytes("test data");
            mocks.MockQueueStore.Setup(q => q.Dequeue()).Returns(new ItemBase() { ResourceId = id });
            mocks.MockRawBlobStore.Setup(b => b.Retrieve(id)).Returns(expected);

            var actual = store.RetrieveForProcessing();

            Assert.AreEqual(expected, actual.File);
        }