-
Hi I found this code from the MudBlazor repo. In this code to load the Enums I need to add the following tag to the view if dont add it mud select item will be zero. is there ay possible way to load the items without adding the [Fact]
public async Task SelectWithEnumTest()
{
var comp = Context.RenderComponent<SelectWithEnumTest>()
var select = comp.FindComponent<MudSelect<MyEnum>>();
var input = comp.Find("div.mud-input-control");
select.Instance.Value.Should().Be(default(MyEnum));
select.Instance.Text.Should().Be(default(MyEnum).ToString());
comp.Find("input").Attributes["value"]?.Value.Should().Be("First");
comp.RenderCount.Should().Be(1);
input.Click();
comp.WaitForAssertion(() => comp.FindAll("div.mud-list-item").Count.Should().BeGreaterThan(0));
var items = comp.FindAll("div.mud-list-item").ToArray();
items[1].Click();
comp.WaitForAssertion(() => comp.Find("input").Attributes["value"]?.Value.Should().Be("Second"));
} This is the view code, you can see the in the view : <MudPopoverProvider></MudPopoverProvider>
Value: @Selected
<br />
<MudSelect IsPreRendered @bind-Value="@Selected">
@foreach (MyEnum item in Enum.GetValues(typeof(MyEnum)))
{
<MudSelectItem Value="@item">@item</MudSelectItem>
}
</MudSelect>
@code {
public static string __description__ = "Initial Text should be the enum's default value.";
public MyEnum Selected { get; set; }
public enum MyEnum
{
First,
Second,
}
} what is the use of MudPopoverProvider ? and instead MudPopoverProvider view can I add to the Unit test like adding a service |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Hey @olemalik I am not sure if I can help here. You have some pretty specific MudBlazor questions which might be better addressed in their official issuetracker. That said I will try my best but take everything what I say with a grain of salt. By the way is this the whole unit test you have posted? I am bit puzzled as the test is
Can you elaborate what you exactly want? I am not sure if I understand your question right. |
Beta Was this translation helpful? Give feedback.
-
Hi! @linkdotnet Thank you for the reply. @egil direct me me here. I have taken the code from the MudBlazor Repo
Initially I wrote my unit test without the but problem is i need to add this tag to my view which I don't want to do it. in addition to that when I add that tag the |
Beta Was this translation helpful? Give feedback.
-
I have manage to remove the |
Beta Was this translation helpful? Give feedback.
I have manage to remove the
MudPopoverProvider
from the component and I have initialized it through the test context after the render of the component.Please refer this link Purpose of MudPopoverProvider