Skip to content

Commit ea0640b

Browse files
committed
test(ComboBox): Simplify popup background color assertion
Refactors the ComboBox popup background UI test to use a direct helper for retrieving the color value. This eliminates the need for manual casting and null checks on the brush type, making the assertion more concise.
1 parent 638894d commit ea0640b

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,10 @@ public async Task ComboBox_UsesDropDownBackgroundResource_WhenBackgroundIsNotSet
279279

280280
var stackPanel = await LoadXaml<StackPanel>($$"""
281281
<StackPanel>
282-
<ComboBox x:Name="Combo"
283-
Width="200">
282+
<ComboBox Width="200">
284283
<ComboBox.Resources>
285284
<SolidColorBrush x:Key="MaterialDesign.Brush.ComboBox.DropDown.Background"
286-
Color="#CC336699" />
285+
Color="#CC336699" />
287286
</ComboBox.Resources>
288287
<ComboBoxItem Content="Android" />
289288
<ComboBoxItem Content="iOS" />
@@ -292,16 +291,14 @@ public async Task ComboBox_UsesDropDownBackgroundResource_WhenBackgroundIsNotSet
292291
</StackPanel>
293292
""");
294293

295-
var comboBox = await stackPanel.GetElement<ComboBox>("Combo");
294+
var comboBox = await stackPanel.GetElement<ComboBox>();
296295
await comboBox.LeftClick(Position.RightCenter);
297296

298297
var popup = await Wait.For(async () => await comboBox.GetElement<ComboBoxPopup>("PART_Popup"));
299-
var popupBackground = await popup.GetProperty<Brush>(Control.BackgroundProperty);
300-
var popupBackgroundBrush = popupBackground as SolidColorBrush;
298+
Color? popupBackground = await popup.GetBackgroundColor();
301299

302300
await Assert.That(popupBackground).IsNotNull();
303-
await Assert.That(popupBackgroundBrush).IsNotNull();
304-
await Assert.That(popupBackgroundBrush!.Color).IsEqualTo((Color)ColorConverter.ConvertFromString("#CC336699"));
301+
await Assert.That(popupBackground).IsEqualTo((Color)ColorConverter.ConvertFromString("#CC336699"));
305302

306303
recorder.Success();
307304
}

0 commit comments

Comments
 (0)