/// <summary> /// 消息接收完成,触发HL7消息接收事件 /// </summary> public void MsgProc() { string msg = Encoding.UTF8.GetString(buff); msg = msg.TrimEnd('\0'); MSGEventArgs e = new MSGEventArgs(msg); EventMsgReceived(this, e); }
//在ctx_eventMsgReceived方法中接收消息,校验结果是否正确 void Context_eventMsgReceived(object sender, EventArgs e) { Context context = (Context)sender; int idx = 0; string[] result1 = { "MSH|1||||\rMSA|2||||||\r" }; //正确结果 MSGEventArgs evt = e as MSGEventArgs; System.Diagnostics.Debug.WriteLine(evt.msg); //调试时显示到输出窗口 Assert.AreEqual(result1[idx++], evt.msg); //与正确结果比较 }