单元测试燃烧模态内的模态组件
一直试图测试在燃烧的模态内呈现的组件。我当然可以通过模拟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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论