单元测试燃烧模态内的模态组件

发布于 2025-01-27 23:13:14 字数 501 浏览 3 评论 0原文

一直试图测试在燃烧的模态内呈现的组件。我当然可以通过模拟imodalService来测试围绕它的代码,但是如果我想测试模态组件本身,我会遇到问题。它们源于对BlazoredModalInstance的呼叫,喜欢BlazoredModalInstance.closeasync(modalResult)

我本来想嘲笑它,但是由于它没有实现任何接口,所以我不能。我尝试创建一个新的BlazoredModal组件,但是它将BlazoredModalInstance作为我无法提供的私人cascadingParameter。

我还尝试使用Bunit渲染BlazoredModalInstance,给它一些modaloptions,然后将实例传递给我的模态组件,但是调用它会导致崩溃(无参考)。

这有可能实现吗?有没有办法提供级联参数而没有参数。

Been trying to unit test the component rendered inside Blazored Modal. I can of course test the code around it by mocking IModalService but if I want to test the modal component itself, I run into problems. And they stem from calls to BlazoredModalInstance, like to BlazoredModalInstance.CloseAsync(ModalResult).

I would have liked to mock it but since it doesn't implement any interface, I can't. I tried to create a new BlazoredModal component, but it takes the BlazoredModalInstance as a private CascadingParameter which I cannot provide.

I have also tried rendering the BlazoredModalInstance with bUnit, giving it some ModalOptions, and passing the instance to my modal component, but calls to it lead to crashes (null reference).

Is this somehow possible to achieve? Is there a way to provide cascading parameters without the parameters.Add(...) way?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文