Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Test]
- public void SelectWithEnumTest()
- {
- var comp = Context.RenderComponent<SelectWithEnumTest>();
- // select elements needed for the test
- 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.MouseDown();
- 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"));
- }
- SelectWithEnumTest.razor
- ------------------------------
- <MudPopoverProvider />
- Value: @_selected
- <br />
- <MudSelect @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.";
- private MyEnum _selected;
- public enum MyEnum
- {
- First,
- Second,
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment