如何使用 MS Moles 向鼹鼠发起事件?

发布于 2024-09-30 23:32:44 字数 156 浏览 0 评论 0原文

Moles 文档描述了如何在类存根上引发事件,但相同的方法不适用于完整的 Mole。您可以将委托添加到添加/删除方法中,但无法手动引发事件。

我能想到的唯一解决方案是在正在测试的类上创建 RaiseEvent() 方法,但这有点违背了使用摩尔的目的。

有什么建议吗?

The Moles documentation describes how to raise events on class stubs but the same method doesn't work with a full Mole. You can add a delegate to the add / remove methods, but you can't manually raise the event.

The only solution I can think of is to create a RaiseEvent() method on the class being tested, but that kinda defeats the point of using moles.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹏雨一样淡蓝的深情 2024-10-07 23:32:44

事实证明,您可以在事件上使用 Add 方法并获取其中的事件处理程序。一旦有了事件处理程序,您就可以手动调用它,模拟事件。

It turns out you can Mole the Add method on the event and grab the event handler there. Once you have the event handler, you can just Invoke it manually, simulating the event.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文