File tree Expand file tree Collapse file tree
StaticInput.UnitTests.Viewer/Components/Tests/Radio
StaticInput.UnitTests/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ @using System .ComponentModel .DataAnnotations
2+
3+ @inject NavigationManager NavigationManager
4+
5+ <EditForm Model =" Input" method =" post" OnValidSubmit =" OnValidSubmit" FormName =" confirm" >
6+ <DataAnnotationsValidator />
7+ <MudStack Row =" true" AlignItems =" AlignItems.Center" >
8+ <MudStaticRadioGroup @bind-Value =" Input.SelectedValue" For =" () => Input.SelectedValue" >
9+ <MudStaticRadio T =" string" Value =" @(" A " )" Color =" Color.Primary" UncheckedColor =" Color.Error" Size =" Size.Medium" >
10+ Option A
11+ </MudStaticRadio >
12+ <MudStaticRadio T =" string" Value =" @(" B " )" Color =" Color.Primary" UncheckedColor =" Color.Info" Size =" Size.Medium" >
13+ Option B
14+ </MudStaticRadio >
15+ </MudStaticRadioGroup >
16+ <MudStaticButton FormAction =" FormAction.Submit" Color =" Color.Primary" Variant =" Variant.Filled" >Submit</MudStaticButton >
17+ </MudStack >
18+ </EditForm >
19+
20+ @code {
21+ [SupplyParameterFromForm ]
22+ private InputModel Input { get ; set ; } = new ();
23+
24+ private void OnValidSubmit () => NavigationManager .NavigateTo (" " );
25+
26+ private sealed class InputModel
27+ {
28+ public string ? SelectedValue { get ; set ; }
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ @using System .ComponentModel .DataAnnotations
2+
3+ @inject NavigationManager NavigationManager
4+
5+ <EditForm Model =" Input" method =" post" OnValidSubmit =" OnValidSubmit" FormName =" confirm" >
6+ <DataAnnotationsValidator />
7+ <MudStack Row =" true" AlignItems =" AlignItems.Center" >
8+ <MudStaticRadioGroup @bind-Value =" Input.SelectedValue" For =" () => Input.SelectedValue" Color =" Color.Primary" >
9+ <MudStaticRadio T =" string" Value =" @(" A " )" Size =" Size.Medium" >
10+ Option A
11+ </MudStaticRadio >
12+ <MudStaticRadio T =" string" Value =" @(" B " )" Size =" Size.Medium" Disabled >
13+ Option B
14+ </MudStaticRadio >
15+ <MudStaticRadio T =" string" Value =" @(" C " )" Size =" Size.Medium" >
16+ Option C
17+ </MudStaticRadio >
18+ </MudStaticRadioGroup >
19+ <MudStaticButton FormAction =" FormAction.Submit" Color =" Color.Primary" Variant =" Variant.Filled" >Submit</MudStaticButton >
20+ </MudStack >
21+ </EditForm >
22+
23+ @code {
24+ [SupplyParameterFromForm ]
25+ private InputModel Input { get ; set ; } = new ();
26+
27+ private void OnValidSubmit () => NavigationManager .NavigateTo (" " );
28+
29+ private sealed class InputModel
30+ {
31+ public string ? SelectedValue { get ; set ; }
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ <MudStaticRadioGroup @bind-Value =" SelectedValue" CheckedIcon =" @Icons.Material.Filled.CheckBox" UncheckedIcon =" @Icons.Material.Filled.CheckBoxOutlineBlank" >
2+ <MudStaticRadio Value =" @(" A " )" >
3+ Option A
4+ </MudStaticRadio >
5+
6+ <MudStaticRadio Value =" @(" B " )" >
7+ Option B
8+ </MudStaticRadio >
9+ </MudStaticRadioGroup >
10+
11+ @code {
12+ private string SelectedValue { get ; set ; } = " A" ;
13+ }
Original file line number Diff line number Diff line change 1+ @using System .ComponentModel .DataAnnotations
2+
3+ @inject NavigationManager NavigationManager
4+
5+ <EditForm Model =" Input" method =" post" OnValidSubmit =" OnValidSubmit" FormName =" confirm" >
6+ <DataAnnotationsValidator />
7+ <MudStack Row =" true" AlignItems =" AlignItems.Center" >
8+ <MudStaticRadioGroup @bind-Value =" Input.SelectedValue" For =" () => Input.SelectedValue" Color =" Color.Primary" UncheckedColor =" Color.Secondary" >
9+ <MudStaticRadio T =" string" Value =" @(" A " )" Size =" Size.Medium" >
10+ Option A
11+ </MudStaticRadio >
12+ <MudStaticRadio T =" string" Value =" @(" B " )" Size =" Size.Medium" >
13+ Option B
14+ </MudStaticRadio >
15+ <MudStaticRadio T =" string" Value =" @(" C " )" Size =" Size.Medium" >
16+ Option C
17+ </MudStaticRadio >
18+ </MudStaticRadioGroup >
19+ <MudStaticButton FormAction =" FormAction.Submit" Color =" Color.Primary" Variant =" Variant.Filled" >Submit</MudStaticButton >
20+ </MudStack >
21+ </EditForm >
22+
23+ @code {
24+ [SupplyParameterFromForm ]
25+ private InputModel Input { get ; set ; } = new ();
26+
27+ private void OnValidSubmit () => NavigationManager .NavigateTo (" " );
28+
29+ protected override void OnInitialized ()
30+ {
31+ Input .SelectedValue = " C" ;
32+
33+ base .OnInitialized ();
34+ }
35+
36+ private sealed class InputModel
37+ {
38+ public string ? SelectedValue { get ; set ; }
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ @using System .ComponentModel .DataAnnotations
2+
3+ @inject NavigationManager NavigationManager
4+
5+ <EditForm Model =" Input" method =" post" OnValidSubmit =" OnValidSubmit" FormName =" confirm" >
6+ <DataAnnotationsValidator />
7+ <MudStack Row =" true" AlignItems =" AlignItems.Center" >
8+ <MudStaticRadioGroup @bind-Value =" Input.SelectedValue" For =" () => Input.SelectedValue" Color =" Color.Primary" >
9+ <MudStaticRadio T =" string" Value =" @(" A " )" Size =" Size.Medium" >
10+ Option A
11+ </MudStaticRadio >
12+ <MudStaticRadio T =" string" Value =" @(" B " )" Size =" Size.Medium" >
13+ Option B
14+ </MudStaticRadio >
15+ <MudStaticRadio T =" string" Value =" @(" C " )" Size =" Size.Medium" >
16+ Option C
17+ </MudStaticRadio >
18+ </MudStaticRadioGroup >
19+ <MudStaticButton FormAction =" FormAction.Submit" Color =" Color.Primary" Variant =" Variant.Filled" >Submit</MudStaticButton >
20+ </MudStack >
21+ </EditForm >
22+
23+ @code {
24+ [SupplyParameterFromForm ]
25+ private InputModel Input { get ; set ; } = new ();
26+
27+ private void OnValidSubmit () => NavigationManager .NavigateTo (" " );
28+
29+ private sealed class InputModel
30+ {
31+ [Required (AllowEmptyStrings = false , ErrorMessage = " Selection required!" )]
32+ public string ? SelectedValue { get ; set ; }
33+ }
34+ }
Original file line number Diff line number Diff line change @@ -43,8 +43,8 @@ public void MudStaticRadio_Should_Have_Correct_Checked_State()
4343 radioA . Should ( ) . NotBeNull ( ) ;
4444 radioB . Should ( ) . NotBeNull ( ) ;
4545
46- radioA . HasAttribute ( "checked" ) . Should ( ) . BeTrue ( ) ;
47- radioB . HasAttribute ( "checked" ) . Should ( ) . BeFalse ( ) ;
46+ radioA ! . HasAttribute ( "checked" ) . Should ( ) . BeTrue ( ) ;
47+ radioB ! . HasAttribute ( "checked" ) . Should ( ) . BeFalse ( ) ;
4848 }
4949
5050 [ Fact ]
@@ -56,8 +56,8 @@ public void MudStaticRadio_Icon_Should_Reflect_Checked_State()
5656 IElement radioA = radioInputs . First ( r => r . GetAttribute ( "value" ) == "A" ) ;
5757 IElement radioB = radioInputs . First ( r => r . GetAttribute ( "value" ) == "B" ) ;
5858
59- IElement ? iconA = radioA . ParentElement . QuerySelector ( ".mud-icon-root" ) ;
60- IElement ? iconB = radioB . ParentElement . QuerySelector ( ".mud-icon-root" ) ;
59+ IElement ? iconA = radioA . ParentElement ! . QuerySelector ( ".mud-icon-root" ) ;
60+ IElement ? iconB = radioB . ParentElement ! . QuerySelector ( ".mud-icon-root" ) ;
6161
6262 iconA . Should ( ) . NotBeNull ( "The A radio input should be rendered." ) ;
6363 iconB . Should ( ) . NotBeNull ( "The B radio input should be rendered." ) ;
You can’t perform that action at this time.
0 commit comments