-1
我有一個應用程序連接到串行端口並分配DataReceived事件。繼承SerialPort並手動觸發DataReceived事件
sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string input = sp.ReadExisting();
}
我想創建TestSerialPort類,它繼承了SerialPort並允許我手動觸發DataReceived事件。類還應該重寫ReadExisting(),以便我可以返回測試值。