C# - 通过 IBM Websphere MQ 接收到的单元测试消息

标签 c# unit-testing ibm-mq

我是 IBM Websphere MQ 的新手。

在我们的项目中,我已经实现了从 IBM MQ 读取消息的代码。

我已经安装了 IBM WebSphere 客户端,我正在使用 IBM.XMSIBM.XMS.Client.WMQ 的引用来创建连接并从排队。

XMSFactoryFactory xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
IConnectionFactory cf = xff.CreateConnectionFactory();

我已经设置了必要的属性,如 HostName、Channel、Port、QueueManager。

我已经创建了 MessageListener:

MessageListener messageListener = new MessageListener(Method to process the message);

我已将监听器分配给消费者:

consumer.MessageListener = messageListener;

我能够连接到队列管理器,读取消息并在 WPF 窗口中显示该消息。

现在对于上面的代码,我必须编写单元测试。

据我所知,在单元测试中我们不会创建连接并从队列中读取,所以我如何模拟上面的代码以便我可以传递虚拟消息并检查它。

最佳答案

您调用的 XMS API 实际上将与队列管理器进行通信。因此,如果没有队列管理器,API 将会失败,单元测试也会失败。

关于C# - 通过 IBM Websphere MQ 接收到的单元测试消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38080068/

相关文章:

Spring-JMS(Websphere MQ)

c# - 通过 JSON 将数组发送到 MVC Controller ?

c# - 另一个类中的 WPF 事件处理程序

unit-testing - JaCoCo 的分支覆盖,IntelliJ 的 Emma

java - 使用 Mockito 模拟助手类

ios - Quartz Core 干扰正在运行的单元测试

java - IBM MQ : Any way to get connection interruption notification?

ibm-mq - 如何更改 WebSphere MQ Explorer 中的语言?

c# - Linq代码重构

c# - 在运行时获取继承的对象类型