本文整理汇总了C#中TestMessage.Send方法的典型用法代码示例。如果您正苦于以下问题:C# TestMessage.Send方法的具体用法?C# TestMessage.Send怎么用?C# TestMessage.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestMessage
的用法示例。
在下文中一共展示了TestMessage.Send方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Msmq_Send
public void Msmq_Send()
{
var msmq = DistributedApplication.ClusterChannel as MsmqChannelProvider;
// init: purge queues
msmq._receiveQueue.Purge();
for (var i = 0; i < msmq._sendQueues.Count; i++)
{
var sendqueue = msmq._sendQueues[i];
sendqueue.Purge();
}
// distribute a single message, and check remote queues if message arrived
var msg = new TestMessage();
msg.Send();
var formatter = new BinaryMessageFormatter();
try
{
for (var i = 0; i < msmq._sendQueues.Count; i++)
{
var sendqueue = msmq._sendQueues[i];
var recvmsg = sendqueue.Receive(TimeSpan.FromSeconds(3));
var recvtestmsg = formatter.Deserialize(recvmsg.Body as Stream) as TestMessage;
Assert.IsTrue(recvtestmsg.Message == msg.Message, "Received message differs from message that was sent."); // check if we received the message that we have sent
}
}
catch (System.Messaging.MessageQueueException mex)
{
if (mex.MessageQueueErrorCode == System.Messaging.MessageQueueErrorCode.IOTimeout)
{
Assert.Fail("Receiving test message from remote queue timed out.");
}
}
}