Пример #1
0
        public void TestMessageCreateSimple()
        {
            var messageString = TextMessageUtil.CreateMessage("TestTopic", "fieldNameOne", "fieldValueOne");

            Assert.AreEqual(true, messageString.Contains("MSTimestamp"));
            Assert.AreEqual(true, messageString.Contains("MSTopicName"));
            Assert.AreEqual(true, messageString.Contains("TestTopic"));
            Assert.AreEqual(true, messageString.Contains("fieldNameOne"));
            Assert.AreEqual(true, messageString.Contains("fieldValueOne"));
        }
Пример #2
0
        public void TestHandleMessage()
        {
            var handler         = new TopicHandler(ReceivedMessage);
            var testTextMessage = new MockTextMessage("Test.Topic");
            var testMessage     = TextMessageUtil.CreateMessage("Test.Topic", "FieldName", "FieldValue");

            testTextMessage.Text = testMessage;
            testTextMessage.Properties.SetString("BrokerUrl", "tcp://localhost:60606");

            handler.OnMessageHandler(testTextMessage);
        }
Пример #3
0
        protected static string PublishTestMessage(Broker broker, string testTopic, IDictionary <string, string> message)
        {
            var session     = broker.Connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
            var producer    = session.CreateProducer(session.GetTopic(testTopic));
            var messageBody = TextMessageUtil.CreateMessage(testTopic, message);
            var textMessage = producer.CreateTextMessage(messageBody);

            producer.Send(textMessage);

            return(textMessage.NMSMessageId);
        }
Пример #4
0
        public void TestMessageCreate()
        {
            IDictionary <string, string> testMessage = new SortedDictionary <string, string> {
                { "fieldNameOne", "fieldValueOne" },
                { "fieldNameTwo", "fieldValueTwo" },
                { "fieldNameThree", "fieldValueThree" },
                { "fieldNameFour", "fieldValueFour" }
            };

            var messageString = TextMessageUtil.CreateMessage(testMessage);

            Assert.AreEqual(MessageString, messageString.Substring(0, 113));
            Assert.AreEqual(true, messageString.Contains("MSTimestamp"));
        }