public void UnitTestConstructorWithQueueMessageElementAndMessageTextPropertyAccess()
 {
     // <QueueMessage>
     //   <MessageText>PFN0dWZmIC8+</MessageText>
     // </QueueMessage>
     // "PFN0dWZmIC8+" = "<Stuff />" base 64 encoded.
     XElement queueMessageElement = new XElement(
         "QueueMessage",
         new XElement("MessageText", "PFN0dWZmIC8+"));
     QueueMessage queueMessage = new QueueMessage(queueMessageElement);
     Assert.AreEqual("<Stuff />", queueMessage.MessageText);
 }
        public QueueMessage[] GetMessages()
        {
            IEnumerable<XElement> queueMessageElements = this.queueMessagesListElement.Elements("QueueMessage");
            ArrayList list = new ArrayList();
            foreach (XElement queueMessageElement in queueMessageElements)
            {
                QueueMessage queueMessage = new QueueMessage(queueMessageElement);
                list.Add(queueMessage);
            }

            return (QueueMessage[])list.ToArray(typeof(QueueMessage));
        }
예제 #3
0
        public bool PutMessage(string queueName, string messageBody)
        {
            if (string.IsNullOrEmpty(queueName))
            {
                throw new ArgumentException("The Queue Name may not be null or empty.", "queueName");
            }

            if (string.IsNullOrEmpty(messageBody))
            {
                throw new ArgumentException("The Message Body may not be null or empty.", "messageBody");
            }

            try
            {
                string message = new QueueMessage(messageBody).GetRawXml();
                HttpWebRequest httpWebRequest = this.storageServiceRequest.Create(RequestMethod.Post, queueName + "/messages", message);
                HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();
                response.Close();
                return true;
            }
            catch (WebException ex)
            {
                HttpWebResponse httpWebResponse = (HttpWebResponse)ex.Response;
                if (ex.Status == WebExceptionStatus.ProtocolError &&
                    ex.Response != null &&
                    httpWebResponse.StatusCode == HttpStatusCode.Conflict)
                {
                    return false;
                }

                throw;
            }
        }
 public void UnitTestConstructorWithMessageTextAndMessageTextPropertyAccess()
 {
     QueueMessage queueMessage = new QueueMessage("<MyMessage />");
     Assert.AreEqual("<MyMessage />", queueMessage.MessageText);
 }