public void LogTwoMessagesToQueueAndBeAbleToReadBothOfThem()
        {
            string path = @"FormatName:DIRECT=OS:" + CommonUtil.MessageQueuePath;

            MsmqSinkData sinkParams = new MsmqSinkData();

            sinkParams.QueuePath = path;

            MsmqSink sink = new MsmqSink();

            sink.Initialize(new TestLogSinkConfigurationView(sinkParams));

            CommonUtil.SendTestMessage(sink);

            using (MessageQueue mq = new MessageQueue(path))
            {
                Message msg = mq.Receive(new TimeSpan(0, 0, 1));
                mq.Close();
                msg.Formatter = new XmlMessageFormatter(new string[] { "System.String,mscorlib" });
                Assert.AreEqual(CommonUtil.FormattedMessage, msg.Body.ToString());
            }

            CommonUtil.SendTestMessage(sink);
            using (MessageQueue mq = new MessageQueue(path))
            {
                Message msg = mq.Receive(new TimeSpan(0, 0, 1));
                mq.Close();
                msg.Formatter = new XmlMessageFormatter(new string[] { "System.String,mscorlib" });
                Assert.AreEqual(CommonUtil.FormattedMessage, msg.Body.ToString());
            }
        }
Beispiel #2
0
        private MsmqSink CreateSink(MsmqSinkData msmqSinkData)
        {
            MsmqSink msmqSink = new MsmqSink();

            msmqSink.Initialize(new TestLogSinkConfigurationView(msmqSinkData));
            return(msmqSink);
        }
        public void LogTwoMessagesToQueueAndBeAbleToReadBothOfThem()
        {
            string path = @"FormatName:DIRECT=OS:" + CommonUtil.MessageQueuePath;

            MsmqSinkData sinkParams = new MsmqSinkData();
            sinkParams.QueuePath = path;

            MsmqSink sink = new MsmqSink();
            sink.Initialize(new TestLogSinkConfigurationView(sinkParams));

            CommonUtil.SendTestMessage(sink);

            using (MessageQueue mq = new MessageQueue(path))
            {
                Message msg = mq.Receive(new TimeSpan(0, 0, 1));
                mq.Close();
                msg.Formatter = new XmlMessageFormatter(new string[] {"System.String,mscorlib"});
                Assert.AreEqual(CommonUtil.FormattedMessage, msg.Body.ToString());
            }

            CommonUtil.SendTestMessage(sink);
            using (MessageQueue mq = new MessageQueue(path))
            {
                Message msg = mq.Receive(new TimeSpan(0, 0, 1));
                mq.Close();
                msg.Formatter = new XmlMessageFormatter(new string[] {"System.String,mscorlib"});
                Assert.AreEqual(CommonUtil.FormattedMessage, msg.Body.ToString());
            }
        }
Beispiel #4
0
        public void InvalidQueuePath()
        {
            string path = @"INVALID PATH";

            MsmqSinkData sinkParams = new MsmqSinkData("MsmqSink");

            sinkParams.QueuePath = path;
            MsmqSink sink = CreateSink(sinkParams);

            sink.SendMessage(new LogEntry());
        }
Beispiel #5
0
        public void QueueDoesNotExist()
        {
            // delete the queue
            CommonUtil.DeletePrivateTestQ();

            MsmqSinkData sinkParams = new MsmqSinkData("MsmqSink");

            sinkParams.QueuePath = CommonUtil.MessageQueuePath;
            MsmqSink sink = CreateSink(sinkParams);

            try
            {
                CommonUtil.SendTestMessage(sink);
            }
            finally
            {
                CommonUtil.CreatePrivateTestQ();
            }
        }
Beispiel #6
0
        public void LogMessageToMSMQ()
        {
            string path = @"FormatName:DIRECT=OS:" + CommonUtil.MessageQueuePath;

            MsmqSinkData sinkParams = new MsmqSinkData("MsmqSink");

            sinkParams.QueuePath       = path;
            sinkParams.MessagePriority = MessagePriority.Low;
            MsmqSink sink = CreateSink(sinkParams);

            CommonUtil.SendTestMessage(sink);

            MessageQueue mq = new MessageQueue(path);

            mq.MessageReadPropertyFilter.Priority = true;
            Message msg = mq.Receive(new TimeSpan(0, 0, 1));

            msg.Formatter = new XmlMessageFormatter(new string[] { "System.String,mscorlib" });

            mq.Close();
            mq = null;
            Assert.AreEqual(MessagePriority.Low, msg.Priority);
            Assert.AreEqual(CommonUtil.FormattedMessage, msg.Body.ToString());
        }
Beispiel #7
0
 private MsmqSink CreateSink(MsmqSinkData msmqSinkData)
 {
     MsmqSink msmqSink = new MsmqSink();
     msmqSink.Initialize(new TestLogSinkConfigurationView(msmqSinkData));
     return msmqSink;
 }
Beispiel #8
0
        public void Constructor()
        {
            MsmqSink sink = CreateSink(new MsmqSinkData("MsmqSink"));

            Assert.IsNotNull(sink);
        }