I want to make some tests for a modal component made in blazor with mudblazor.
Here's my component
ModalComplejo.razor
<MudDialog>
<TitleContent>@Titulo</TitleContent>
<DialogContent>
@Contenido
</DialogContent>
<DialogActions>
@Botonera
</DialogActions>
</MudDialog>
@code {
[Parameter, EditorRequired]
public RenderFragment Titulo { get; set; } = default!;
[Parameter, EditorRequired]
public RenderFragment Contenido { get; set; } = default!;
[Parameter, EditorRequired]
public RenderFragment Botonera { get; set; } = default!;
}
ModalComplejoTests.razor
@code {
[Fact]
public void RenderModalComplejo()
{
Services.AddSingleton<MudDialogProvider>();
Services.AddSingleton<IDialogService, DialogService>();
var cut = Render(
@<ModalComplejo>
<Titulo>
<h1>Caso 1122</h1>
</Titulo>
<Contenido>
<h2>Lorem ipsum</h2>
<p>Lorem ipsum factum...</p>
</Contenido>
<Botonera>
<label for="guardar-btn">Guardar</label>
<input type="button" id="guardar-btn" />
<label for="cerrar-btn">Cerrar</label>
<input type="button" id="cerrar-btn" />
</Botonera>
</ModalComplejo>
);
cut.MarkupMatches("<H1>Hello World<H1>");
// var ds = new DialogService();
// ds.Show<ModalComplejo>()
}
}
As you can see, I'm using a templated razor delegate to define de test. I debugged it and the markup always return empty.
I think this has to do with the fact that the modal is never triggered. I should open it first and then the markup will appear, but I don't have an idea how to accomplish that, any ideas how to fix this? or maybe it is another issue that I'm not seeing.
