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()); } }
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()); } }
public void InvalidQueuePath() { string path = @"INVALID PATH"; MsmqSinkData sinkParams = new MsmqSinkData("MsmqSink"); sinkParams.QueuePath = path; MsmqSink sink = CreateSink(sinkParams); sink.SendMessage(new LogEntry()); }
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(); } }
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()); }
private MsmqSink CreateSink(MsmqSinkData msmqSinkData) { MsmqSink msmqSink = new MsmqSink(); msmqSink.Initialize(new TestLogSinkConfigurationView(msmqSinkData)); return msmqSink; }
public void Constructor() { MsmqSink sink = CreateSink(new MsmqSinkData("MsmqSink")); Assert.IsNotNull(sink); }