public void PutLargeXmlMessage() { string testFileName = Path.Combine(testMessageFolder, "InventoryReport_2.xml"); using (ICloudBlobStorage blobStorage = GetCloudBlobStorage()) using (ICloudQueueStorage queueStorage = GetCloudQueueStorage()) { LargeQueueMessageInfo largeMsgInfo = LargeQueueMessageInfo.Create(testQueueName); XDocument testMessage = XDocument.Load(testFileName); queueStorage.Clear(testQueueName); queueStorage.Put <XDocument>(testQueueName, testMessage); int blobCount = blobStorage.GetCount(largeMsgInfo.ContainerName); XDocument msgFromQueue = queueStorage.Get <XDocument>(testQueueName); Assert.IsNotNull(msgFromQueue, "Unable to find message on the queue"); Assert.IsTrue(String.Compare(testMessage.ToString(), msgFromQueue.ToString(), false) == 0, "Message content is different"); Assert.IsTrue(blobCount == 1, "Blob storage must contain the message data"); bool deleted = queueStorage.Delete <XDocument>(msgFromQueue); int queueLength = queueStorage.GetCount(testQueueName); Assert.IsTrue(deleted, "Message has not been deleted by some reasons"); Assert.IsTrue(queueLength == 0, "Queue is not empty by some reasons"); blobCount = blobStorage.GetCount(largeMsgInfo.ContainerName); Assert.IsTrue(blobCount == 0, "Blob storage is not empty by some reasons"); } }
public void PutLargeBinaryMessage() { int largeMessageSize = 2 * 1024 * 1024; var largeMessage = new byte[largeMessageSize]; randGenerator.NextBytes(largeMessage); using (ICloudBlobStorage blobStorage = GetCloudBlobStorage()) using (ICloudQueueStorage queueStorage = GetCloudQueueStorage()) { LargeQueueMessageInfo largeMsgInfo = LargeQueueMessageInfo.Create(testQueueName); queueStorage.Clear(testQueueName); queueStorage.Put <byte[]>(testQueueName, largeMessage); int blobCount = blobStorage.GetCount(largeMsgInfo.ContainerName); byte[] msgFromQueue = queueStorage.Get <byte[]>(testQueueName); Assert.IsNotNull(msgFromQueue, "Unable to find message on the queue"); var matchedBytes = msgFromQueue.Where((value, index) => { return(largeMessage[index] == value); }); Assert.IsTrue(matchedBytes.Count() == largeMessageSize, "Message content is different"); Assert.IsTrue(blobCount == 1, "Blob storage must contain the message data"); bool deleted = queueStorage.Delete <byte[]>(msgFromQueue); int queueLength = queueStorage.GetCount(testQueueName); Assert.IsTrue(deleted, "Message has not been deleted by some reasons"); Assert.IsTrue(queueLength == 0, "Queue is not empty by some reasons"); blobCount = blobStorage.GetCount(largeMsgInfo.ContainerName); Assert.IsTrue(blobCount == 0, "Blob storage is not empty by some reasons"); } }