Guest User

Untitled

a guest
Dec 16th, 2025
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. [Test]
  2. public void SelectWithEnumTest()
  3. {
  4. var comp = Context.RenderComponent<SelectWithEnumTest>();
  5. // select elements needed for the test
  6. var select = comp.FindComponent<MudSelect<MyEnum>>();
  7. var input = comp.Find("div.mud-input-control");
  8.  
  9. select.Instance.Value.Should().Be(default(MyEnum));
  10. select.Instance.Text.Should().Be(default(MyEnum).ToString());
  11.  
  12. comp.Find("input").Attributes["value"]?.Value.Should().Be("First");
  13. comp.RenderCount.Should().Be(1);
  14. input.MouseDown();
  15. comp.WaitForAssertion(() => comp.FindAll("div.mud-list-item").Count.Should().BeGreaterThan(0));
  16. var items = comp.FindAll("div.mud-list-item").ToArray();
  17. items[1].Click();
  18. comp.WaitForAssertion(() => comp.Find("input").Attributes["value"]?.Value.Should().Be("Second"));
  19. }
  20.  
  21.  
  22. SelectWithEnumTest.razor
  23. ------------------------------
  24. <MudPopoverProvider />
  25.  
  26. Value: @_selected
  27. <br />
  28. <MudSelect @bind-Value="@_selected">
  29. @foreach (MyEnum item in Enum.GetValues(typeof(MyEnum)))
  30. {
  31. <MudSelectItem Value="@item">@item</MudSelectItem>
  32. }
  33. </MudSelect>
  34.  
  35. @code {
  36. public static string __description__ = "Initial Text should be the enum's default value.";
  37.  
  38. private MyEnum _selected;
  39.  
  40. public enum MyEnum
  41. {
  42. First,
  43. Second,
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment