我有这个文本加载器类,我正在尝试为其编写测试。它的一个方法执行一个 RaiseEvent ,并将 CancelEventArgs 作为参数解析,所以是这样的:
Private Sub FireThisEvent()
cancelEvent created here
RaiseEvent HelloWorld(cancelEvent)
If cancelEvent.Cancel Then
'do smthg
End If
End Sub
事件的处理程序HelloWorld是我的 UI 类,它会弹出一个让用户决定是或否的弹出窗口,然后设置cancelEvent.Cancel为Trueor 或False。然后上述方法检查cancelEvent并相应地执行操作。
我的问题是,因为我只测试加载器类(而不是 UI),所以在引发事件之后如何操作,cancelEvent以便我可以测试 when cancelEvent.CancelisTrue和 then ,when it is False。谢谢你。
我会模拟 UI 类吗?