I am new to bUnit and Blazor, so maybe what I want is not possible to achieve, but I am using MudBlazor and I want to check if the ChildContent of my MudDrawer contains a certain parameter.
My razor component is:
<MudDrawer @bind-Open="@Open" Elevation="0">
<MudDrawerHeader>
<MudText Typo="Typo.h6">Edison</MudText>
</MudDrawerHeader>
<MyCustomComponent Param1="_myParam1" Param2="_myParam2" />
</MudDrawer>
@code {
[Parameter] public bool Open { get; set; }
private string _myParam1 = string.Empty;
private Dictionary<string, bool> _myParam2 = [];
protected override void OnInitialized(){
_myParam2.Add("Something", true);
}
}
The test I have created so far, using xUnit is:
@inherits TestContext
@code{
[Fact]
public void ShouldSendCorrectValuesToParameter()
{
ComponentFactories.AddStub<MudDrawer>();
var cut = RenderComponent<MyComponent>(parameters => parameters.Add("Open", true));
IRenderedComponent<Stub<MudDrawer>> drawerStub = cut.FindComponent<Stub<MudDrawer>>();
drawerStub.Instance.Parameters.Get(p => p.Open).Should().BeTrue();
// Here I want to check if MyCustomComponent receives both parameters correctly. Is this possible?
My question is: Is it possible to get/create the ChildContent and verify if MyCustomComponent is receiving the correct parameters?
Thank you in advance,