diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml index 36ffa01414..389c02a410 100644 --- a/.github/workflows/build_artifacts.yml +++ b/.github/workflows/build_artifacts.yml @@ -32,8 +32,8 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.x 8.x + 9.x - name: Restore dependencies run: dotnet restore ${{ env.solution }} @@ -54,7 +54,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: Screenshots-${{ github.run_number }} - path: ${{ github.workspace }}tests\MaterialDesignThemes.UITests\bin\${{ inputs.build-configuration }}\net8.0-windows7\Screenshots + path: ${{ github.workspace }}\tests\MaterialDesignThemes.UITests\bin\${{ inputs.build-configuration }}\net9.0-windows\Screenshots if-no-files-found: ignore - name: Build NuGets diff --git a/Directory.packages.props b/Directory.packages.props index b58226de08..37ca871f37 100644 --- a/Directory.packages.props +++ b/Directory.packages.props @@ -1,9 +1,9 @@ - + - + @@ -14,7 +14,7 @@ - + @@ -24,11 +24,10 @@ + + - - - - + diff --git a/MaterialDesignToolkit.Full.sln b/MaterialDesignToolkit.Full.sln index d27338256c..6414dbdcc2 100644 --- a/MaterialDesignToolkit.Full.sln +++ b/MaterialDesignToolkit.Full.sln @@ -33,9 +33,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.packages.props = Directory.packages.props .config\dotnet-tools.json = .config\dotnet-tools.json global.json = global.json - MaterialDesignColors.nuspec = MaterialDesignColors.nuspec - MaterialDesignThemes.MahApps.nuspec = MaterialDesignThemes.MahApps.nuspec - MaterialDesignThemes.nuspec = MaterialDesignThemes.nuspec build\MigrateBrushes.ps1 = build\MigrateBrushes.ps1 nuget.config = nuget.config README.md = README.md diff --git a/global.json b/global.json index c19a2e057c..ccbe73ca13 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100", + "version": "9.0.300", "rollForward": "latestMinor" } } diff --git a/src/MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj b/src/MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj index 4a38274b38..e434e02469 100644 --- a/src/MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj +++ b/src/MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj @@ -2,7 +2,7 @@ WinExe - net472;net6.0-windows;net8.0-windows + net472;net8.0-windows true ..\ true diff --git a/src/MainDemo.Wpf/App.xaml b/src/MainDemo.Wpf/App.xaml index 78e99066d6..a5c2537ae3 100644 --- a/src/MainDemo.Wpf/App.xaml +++ b/src/MainDemo.Wpf/App.xaml @@ -22,7 +22,7 @@ If you would prefer to use your own colors, there is an option for that as well: PrimaryColor and SecondaryColor also support the constant string "Inherit" to specify the color should use the system theme accent color --> - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -1129,7 +1127,7 @@ - + @@ -1217,5 +1215,4 @@ - diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml index f7d21bd418..e65875261b 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml @@ -80,6 +80,7 @@ + @@ -108,7 +109,7 @@ @@ -178,7 +179,7 @@ + @@ -272,17 +274,18 @@ Clip="{Binding ElementName=GeometryEllipse, Path=RenderedGeometry}" ClipToBounds="True" Focusable="False" - SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"> - - - - - - - + SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> + + + + + + + PopupAnimation="{TemplateBinding PopupAnimation}"> diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml index 4ad30d2d68..7fbe3d00a9 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml @@ -184,26 +184,26 @@ StrokeThickness="3"> - - + + - + - + - + - + - + @@ -212,7 +212,9 @@ - + diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml index 00df04c542..8bca63e894 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml @@ -1,10 +1,10 @@  - - - diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Snackbar.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Snackbar.xaml index 97c582c8f8..657831e36b 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Snackbar.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Snackbar.xaml @@ -88,18 +88,18 @@ ContentStringFormat="{TemplateBinding ActionContentStringFormat}" ContentTemplate="{TemplateBinding ActionContentTemplate}" ContentTemplateSelector="{TemplateBinding ActionContentTemplateSelector}" - Style="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wpf:Snackbar}}, Path=ActionButtonStyle}" + Style="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wpf:Snackbar}}, Path=ActionButtonStyle, FallbackValue={x:Null}}" Visibility="{TemplateBinding ActionContent, Converter={x:Static converters:NullableToVisibilityConverter.CollapsedInstance}}"> - - - + + + - @@ -223,5 +223,4 @@ - diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml index b97a2f48d4..d6279585d8 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml @@ -23,7 +23,7 @@ @@ -486,7 +489,7 @@ @@ -557,7 +560,7 @@ - + @@ -594,7 +597,6 @@ - @@ -669,7 +671,6 @@ Visibility="Collapsed" /> - - + - diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml index cb2d9de90c..5f09d6a8ef 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml @@ -35,7 +35,7 @@ - + @@ -202,5 +202,4 @@ - diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml index 66b5d16d89..52e85b15ca 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml @@ -5,7 +5,7 @@ - + - diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeListView.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeListView.xaml index c2f8a0afa4..0f13b84415 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeListView.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeListView.xaml @@ -98,8 +98,8 @@ - - + + @@ -107,7 +107,7 @@ - + @@ -234,7 +234,7 @@ - + diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeView.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeView.xaml index 644d3a6f18..9b5cb01956 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeView.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeView.xaml @@ -165,8 +165,8 @@ - - + + @@ -379,7 +379,7 @@ - + diff --git a/src/MaterialDesignThemes.Wpf/TreeListView.cs b/src/MaterialDesignThemes.Wpf/TreeListView.cs index e5c778773c..8f907f73b9 100644 --- a/src/MaterialDesignThemes.Wpf/TreeListView.cs +++ b/src/MaterialDesignThemes.Wpf/TreeListView.cs @@ -51,24 +51,24 @@ protected override DependencyObject GetContainerForItemOverride() protected override bool IsItemItsOwnContainerOverride(object? item) => item is TreeListViewItem; - protected override void PrepareContainerForItemOverride(DependencyObject element, object? item) - { - base.PrepareContainerForItemOverride(element, item); + //protected override void PrepareContainerForItemOverride(DependencyObject element, object? item) + //{ + // base.PrepareContainerForItemOverride(element, item); - if (element is TreeListViewItem treeListViewItem) - { - int level = 0; - bool isExpanded = false; - int index = ItemContainerGenerator.IndexFromContainer(treeListViewItem); - if (index >= 0 && InternalItemsSource is { } itemsSource) - { - level = itemsSource.GetLevel(index); - isExpanded = itemsSource.GetIsExpanded(index); - } + // if (element is TreeListViewItem treeListViewItem) + // { + // int level = 0; + // bool isExpanded = false; + // int index = ItemContainerGenerator.IndexFromContainer(treeListViewItem); + // if (index >= 0 && InternalItemsSource is { } itemsSource) + // { + // level = itemsSource.GetLevel(index); + // isExpanded = itemsSource.GetIsExpanded(index); + // } - treeListViewItem.PrepareTreeListViewItem(item, this, level, isExpanded); - } - } + // treeListViewItem.PrepareTreeListViewItem(item, this, level, isExpanded); + // } + //} protected override void ClearContainerForItemOverride(DependencyObject element, object item) { @@ -86,11 +86,19 @@ internal void ItemExpandedChanged(TreeListViewItem item) int index = ItemContainerGenerator.IndexFromContainer(item); //Issue 3572 if (index < 0) return; - var children = item.GetChildren().ToList(); - bool isExpanded = item.IsExpanded; + var isExpanded = item.IsExpanded; + var internalIsExpanded = itemsSource.GetIsExpanded(index); + + if (internalIsExpanded == isExpanded) + { + return; + } + itemsSource.SetIsExpanded(index, isExpanded); + if (isExpanded) { + var children = item.GetChildren().ToList(); int parentLevel = itemsSource.GetLevel(index); for (int i = 0; i < children.Count; i++) { diff --git a/src/MaterialDesignThemes.Wpf/TreeListViewItem.cs b/src/MaterialDesignThemes.Wpf/TreeListViewItem.cs index 8aeab1aee8..3c42c8285b 100644 --- a/src/MaterialDesignThemes.Wpf/TreeListViewItem.cs +++ b/src/MaterialDesignThemes.Wpf/TreeListViewItem.cs @@ -146,7 +146,18 @@ public override void OnApplyTemplate() void OnTemplateChanged(object? sender, EventArgs e) { - PrepareTreeListViewItem(Content, TreeListView!, Level, IsExpanded); + int level = 0; + bool isExpanded = false; + int index = TreeListView!.ItemContainerGenerator.IndexFromContainer(this); + + + if (index >= 0 && TreeListView.InternalItemsSource is { } itemsSource) + { + level = itemsSource.GetLevel(index); + isExpanded = itemsSource.GetIsExpanded(index); + } + + PrepareTreeListViewItem(Content, TreeListView, level, isExpanded); } } } diff --git a/src/MaterialDesignThemes.Wpf/UpDownBase.cs b/src/MaterialDesignThemes.Wpf/UpDownBase.cs index e3ecb89407..0617eb7824 100644 --- a/src/MaterialDesignThemes.Wpf/UpDownBase.cs +++ b/src/MaterialDesignThemes.Wpf/UpDownBase.cs @@ -118,7 +118,7 @@ private static void OnNumericValueChanged(DependencyObject d, DependencyProperty if (upDownBase._textBoxField is { } textBox) { - textBox.Text = e.NewValue.ToString(); + textBox.Text = Convert.ToString(e.NewValue, CultureInfo.CurrentCulture); } upDownBase.UpdateDecreaseButtonEnabled(); @@ -201,7 +201,10 @@ public override void OnApplyTemplate() if (_decreaseButton != null) _decreaseButton.Click -= DecreaseButtonOnClick; if (_textBoxField != null) - _textBoxField.TextChanged -= OnTextBoxFocusLost; + { + _textBoxField.TextChanged -= OnTextBoxTextChanged; + _textBoxField.LostFocus -= OnTextBoxLostFocus; + } base.OnApplyTemplate(); @@ -219,22 +222,29 @@ public override void OnApplyTemplate() if (_textBoxField != null) { - _textBoxField.LostFocus += OnTextBoxFocusLost; - _textBoxField.Text = Value?.ToString(); + _textBoxField.TextChanged += OnTextBoxTextChanged; + _textBoxField.LostFocus += OnTextBoxLostFocus; + _textBoxField.Text = Convert.ToString(Value, CultureInfo.CurrentCulture); } } - private void OnTextBoxFocusLost(object sender, EventArgs e) + private void OnTextBoxLostFocus(object sender, EventArgs e) + { + if (_textBoxField is { } textBoxField) + { + textBoxField.Text = Convert.ToString(Value, CultureInfo.CurrentCulture); + } + } + + private void OnTextBoxTextChanged(object sender, EventArgs e) { if (_textBoxField is { } textBoxField) { - if (TryParse(textBoxField.Text, CultureInfo.CurrentUICulture, out T? value)) + if (TryParse(textBoxField.Text, CultureInfo.CurrentCulture, out T? value)) { SetCurrentValue(ValueProperty, ClampValue(value)); } - //NB: Because setting ValueProperty will coerce the value, we re-assign back to the textbox here. - textBoxField.Text = Value?.ToString(); } } diff --git a/src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs b/src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs index ca1354b481..212aadb789 100644 --- a/src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs +++ b/src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs @@ -482,7 +482,7 @@ void WriteBrush(Brush brush, string name) {{indent}}{{indent}}{ {{indent}}{{indent}}{{indent}}IVisualElement textBlock = await panel.GetElement("[Text=\"{{name}}\"]"); {{indent}}{{indent}}{{indent}}Color? textBlockBackground = await textBlock.GetBackgroundColor(); - {{indent}}{{indent}}{{indent}}Assert.Equal(await GetResourceColor("{{brush.Name}}"), textBlockBackground); + {{indent}}{{indent}}{{indent}}await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("{{brush.Name}}")); {{indent}}{{indent}}} """); } diff --git a/tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs b/tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs index 47b0bf905a..919c47035a 100644 --- a/tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs +++ b/tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs @@ -1,13 +1,12 @@ using System.Windows.Media; using MaterialDesignColors.ColorManipulation; -using Xunit; namespace MaterialDesignColors.Wpf.Tests; public class ColorAssistTests { - [Fact] - public void EnsureContrastRatio_AdjustsColor() + [Test] + public async Task EnsureContrastRatio_AdjustsColor() { var background = Color.FromRgb(0xFA, 0xFA, 0xFA); var foreground = Color.FromRgb(0xFF, 0xC1, 0x07); @@ -15,7 +14,7 @@ public void EnsureContrastRatio_AdjustsColor() var adjusted = foreground.EnsureContrastRatio(background, 3.0f); double contrastRatio = adjusted.ContrastRatio(background); - Assert.True(contrastRatio >= 2.9); - Assert.True(contrastRatio <= 3.1); + await Assert.That(contrastRatio).IsGreaterThanOrEqualTo(2.9); + await Assert.That(contrastRatio).IsLessThanOrEqualTo(3.1); } } diff --git a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj index 66ee05538b..079e511042 100644 --- a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj +++ b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj @@ -1,9 +1,12 @@  - net472;net6.0-windows;net8.0-windows + net472;net8.0-windows MaterialDesignColors.Wpf.Tests MaterialDesignColors.Wpf.Tests + true + Exe + true @@ -25,9 +28,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + \ No newline at end of file diff --git a/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs b/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs index d54a25183a..4f3eeac307 100644 --- a/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs +++ b/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs @@ -1,65 +1,62 @@ -using Shouldly; -using Xunit; - -namespace MaterialDesignColors.Wpf.Fixture; +namespace MaterialDesignColors.Wpf.Tests; public class ResourceProviderFixture { - [Fact] - public void ExcludesBlack() + [Test] + public async Task ExcludesBlack() { SwatchesProvider swatchesProvider = new (); bool containsBlack = swatchesProvider.Swatches.Any( swatch => string.Compare(swatch.Name, "Black", StringComparison.InvariantCultureIgnoreCase) == 0); - containsBlack.ShouldBe(false); + await Assert.That(containsBlack).IsFalse(); } - [Fact] - public void IncludesGrey() + [Test] + public async Task IncludesGrey() { SwatchesProvider swatchesProvider = new (); bool containsBlack = swatchesProvider.Swatches.Any( swatch => string.Compare(swatch.Name, "Grey", StringComparison.InvariantCultureIgnoreCase) == 0); - containsBlack.ShouldBe(true); + await Assert.That(containsBlack).IsTrue(); } - [Fact] - public void BrownHasNoSecondary() + [Test] + public async Task BrownHasNoSecondary() { SwatchesProvider swatchesProvider = new (); var brownSwatch = swatchesProvider.Swatches.Single( swatch => swatch.Name == "brown"); - brownSwatch.SecondaryHues.ShouldNotBeNull(); - brownSwatch.SecondaryHues.Count.ShouldBe(0); + await Assert.That(brownSwatch.SecondaryHues).IsNotNull(); + await Assert.That(brownSwatch.SecondaryHues.Count).IsEqualTo(0); } - [Fact] - public void BrownHasPrimaries() + [Test] + public async Task BrownHasPrimaries() { SwatchesProvider swatchesProvider = new (); var brownSwatch = swatchesProvider.Swatches.Single( swatch => swatch.Name == "brown"); - brownSwatch.PrimaryHues.ShouldNotBeNull(); - brownSwatch.PrimaryHues.Count.ShouldBe(10); + await Assert.That(brownSwatch.PrimaryHues).IsNotNull(); + await Assert.That(brownSwatch.PrimaryHues.Count).IsEqualTo(10); } - [Fact] - public void IndigoHasSecondaries() + [Test] + public async Task IndigoHasSecondaries() { SwatchesProvider swatchesProvider = new (); var brownSwatch = swatchesProvider.Swatches.Single( swatch => swatch.Name == "indigo"); - brownSwatch.SecondaryHues.ShouldNotBeNull(); - brownSwatch.SecondaryHues.Count.ShouldBe(4); + await Assert.That(brownSwatch.SecondaryHues).IsNotNull(); + await Assert.That(brownSwatch.SecondaryHues.Count).IsEqualTo(4); } } diff --git a/tests/MaterialDesignThemes.UITests/AllStyles.cs b/tests/MaterialDesignThemes.UITests/AllStyles.cs index 2710e4b0fe..5d3c6c0f01 100644 --- a/tests/MaterialDesignThemes.UITests/AllStyles.cs +++ b/tests/MaterialDesignThemes.UITests/AllStyles.cs @@ -1,40 +1,35 @@ -using System.Reflection; -using MaterialDesignColors; +using MaterialDesignColors; namespace MaterialDesignThemes.UITests; public class AllStyles : TestBase { - public AllStyles(ITestOutputHelper output) - : base(output) - { } - - [Theory] - [InlineData("Button", "MaterialDesignRaisedButton")] - [InlineData("Calendar", "MaterialDesignCalendarPortrait")] - [InlineData("CheckBox", "MaterialDesignCheckBox")] - [InlineData("ComboBox", "MaterialDesignComboBox")] - [InlineData("DataGrid", "MaterialDesignDataGrid")] - [InlineData("DatePicker", "MaterialDesignDatePicker")] - [InlineData("Expander", "MaterialDesignExpander")] - [InlineData("GridSplitter", "MaterialDesignGridSplitter")] - [InlineData("GroupBox", "MaterialDesignGroupBox")] - [InlineData("Label", "MaterialDesignLabel")] - [InlineData("ListBox", "MaterialDesignListBox")] - [InlineData("ListView", "MaterialDesignListView")] - [InlineData("Menu", "MaterialDesignMenu")] - [InlineData("PasswordBox", "MaterialDesignPasswordBox")] - [InlineData("ProgressBar", "MaterialDesignLinearProgressBar")] - [InlineData("RadioButton", "MaterialDesignRadioButton")] - [InlineData("RichTextBox", "MaterialDesignRichTextBox")] - [InlineData("ScrollBar", "MaterialDesignScrollBar")] - [InlineData("ScrollViewer", "MaterialDesignScrollViewer")] - [InlineData("Slider", "MaterialDesignSlider")] - [InlineData("TabControl", "MaterialDesignTabControl")] - [InlineData("TextBox", "MaterialDesignTextBox")] - [InlineData("ToggleButton", "MaterialDesignSwitchToggleButton")] - [InlineData("ToolBar", "MaterialDesignToolBar")] - [InlineData("TreeView", "MaterialDesignTreeView")] + [Test] + [Arguments("Button", "MaterialDesignRaisedButton")] + [Arguments("Calendar", "MaterialDesignCalendarPortrait")] + [Arguments("CheckBox", "MaterialDesignCheckBox")] + [Arguments("ComboBox", "MaterialDesignComboBox")] + [Arguments("DataGrid", "MaterialDesignDataGrid")] + [Arguments("DatePicker", "MaterialDesignDatePicker")] + [Arguments("Expander", "MaterialDesignExpander")] + [Arguments("GridSplitter", "MaterialDesignGridSplitter")] + [Arguments("GroupBox", "MaterialDesignGroupBox")] + [Arguments("Label", "MaterialDesignLabel")] + [Arguments("ListBox", "MaterialDesignListBox")] + [Arguments("ListView", "MaterialDesignListView")] + [Arguments("Menu", "MaterialDesignMenu")] + [Arguments("PasswordBox", "MaterialDesignPasswordBox")] + [Arguments("ProgressBar", "MaterialDesignLinearProgressBar")] + [Arguments("RadioButton", "MaterialDesignRadioButton")] + [Arguments("RichTextBox", "MaterialDesignRichTextBox")] + [Arguments("ScrollBar", "MaterialDesignScrollBar")] + [Arguments("ScrollViewer", "MaterialDesignScrollViewer")] + [Arguments("Slider", "MaterialDesignSlider")] + [Arguments("TabControl", "MaterialDesignTabControl")] + [Arguments("TextBox", "MaterialDesignTextBox")] + [Arguments("ToggleButton", "MaterialDesignSwitchToggleButton")] + [Arguments("ToolBar", "MaterialDesignToolBar")] + [Arguments("TreeView", "MaterialDesignTreeView")] public async Task LoadStyleInIsolation_CanBeLoaded(string controlName, string styleName) { await using var recorder = new TestRecorder(App); @@ -57,7 +52,7 @@ public async Task LoadStyleInIsolation_CanBeLoaded(string controlName, string st await App.Initialize(applicationResourceXaml, Path.GetFullPath("MaterialDesignColors.dll"), Path.GetFullPath("MaterialDesignThemes.Wpf.dll"), - Assembly.GetExecutingAssembly().Location); + System.Reflection.Assembly.GetExecutingAssembly().Location); IWindow window = await App.CreateWindow($$""" """); - Assert.True(await window.GetIsVisible()); + await Assert.That(await window.GetIsVisible()).IsTrue(); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs b/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs index 7247b4d8a6..4de16f29ee 100644 --- a/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs +++ b/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs @@ -17,11 +17,12 @@ public static class MaterialDesignSpec /// public const double MinimumContrastLargeText = 3.0; - public static void AssertContrastRatio(Color foreground, Color background, double minimumContrastRatio) + public static async Task AssertContrastRatio(Color foreground, Color background, double minimumContrastRatio) { const double tolerance = 0.1; - var ratio = ColorAssist.ContrastRatio(foreground, background); - Assert.True(ratio >= minimumContrastRatio - tolerance, $"Contrast ratio '{ratio}' is less than {minimumContrastRatio} with a tolerance of 0.1"); + double ratio = ColorAssist.ContrastRatio(foreground, background); + await Assert.That(ratio).IsGreaterThanOrEqualTo(minimumContrastRatio - tolerance) + .Because($"Contrast ratio '{ratio}' is less than {minimumContrastRatio} with a tolerance of 0.1"); } } diff --git a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj index c75b048ec9..8e78308ec4 100644 --- a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj +++ b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj @@ -1,11 +1,14 @@  - net8.0-windows + net9.0-windows false false true $(NoWarn);CA1707 true + true + Exe + true @@ -19,18 +22,13 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + - - diff --git a/tests/MaterialDesignThemes.UITests/Samples/AutoSuggestBoxes/AutoSuggestTextBoxWithCollectionView.xaml b/tests/MaterialDesignThemes.UITests/Samples/AutoSuggestBoxes/AutoSuggestTextBoxWithCollectionView.xaml index cba573ebb8..12076ca6d9 100644 --- a/tests/MaterialDesignThemes.UITests/Samples/AutoSuggestBoxes/AutoSuggestTextBoxWithCollectionView.xaml +++ b/tests/MaterialDesignThemes.UITests/Samples/AutoSuggestBoxes/AutoSuggestTextBoxWithCollectionView.xaml @@ -14,7 +14,9 @@ materialDesign:HintAssist.HelperText="Name" materialDesign:TextFieldAssist.HasClearButton="True" Text="{Binding AutoSuggestText, UpdateSourceTrigger=PropertyChanged}" - Suggestions="{Binding Suggestions}"> + Suggestions="{Binding Suggestions}" + SelectedItem="{Binding SelectedItem}" + > BaseSuggestions { get; } [ObservableProperty] - private ObservableCollection _suggestions = new(); + private ObservableCollection _suggestions = []; [ObservableProperty] private string? _autoSuggestText; @@ -41,14 +41,14 @@ partial void OnAutoSuggestTextChanged(string? oldValue, string? newValue) public AutoSuggestTextBoxWithTemplateViewModel() { - BaseSuggestions = new() - { + BaseSuggestions = + [ new("Apples"), new("Bananas"), new("Beans"), new("Mtn Dew"), new("Orange"), - }; + ]; Suggestions = new ObservableCollection(BaseSuggestions); } @@ -62,9 +62,7 @@ private static bool IsMatch(string item, string currentText) } } -public class SuggestionThing +public class SuggestionThing(string name) { - public string Name { get; } - - public SuggestionThing(string name) => Name = name; + public string Name { get; } = name; } diff --git a/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs b/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs index 719ead86b2..6d830021a8 100644 --- a/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs +++ b/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs @@ -1,6 +1,6 @@ using System.Collections; using System.ComponentModel; -using System.ComponentModel.DataAnnotations; +using System.Threading; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -46,7 +46,7 @@ private async Task CauseErrors() { Error = "Some error"; ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Text))); - await Task.Delay(100); + await Task.Delay(100, CancellationToken.None); Error += " + more"; ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Text))); } diff --git a/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs b/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs new file mode 100644 index 0000000000..1ae6934500 --- /dev/null +++ b/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs @@ -0,0 +1,51 @@ +using System.Numerics; +using System.Runtime.CompilerServices; +using TUnit.Assertions.AssertConditions; +using TUnit.Assertions.AssertConditions.Interfaces; +using TUnit.Assertions.AssertionBuilders; + +namespace MaterialDesignThemes.Tests.TUnit; + +public static class IsCloseToExtensions +{ + public static IsCloseToWrapper IsCloseTo(this IValueSource valueSource, double expected, double precision, [CallerArgumentExpression(nameof(expected))] string? doNotPopulateThisValue1 = null, [CallerArgumentExpression(nameof(precision))] string? doNotPopulateThisValue2 = null) + { + var assertionBuilder = valueSource.RegisterAssertion(new IsCloseToCondition(expected, precision) + , [doNotPopulateThisValue1, doNotPopulateThisValue2]); + + return new IsCloseToWrapper(assertionBuilder); + } + + public static IsCloseToWrapper IsCloseTo(this IValueSource valueSource, float expected, float precision, [CallerArgumentExpression(nameof(expected))] string? doNotPopulateThisValue1 = null, [CallerArgumentExpression(nameof(precision))] string? doNotPopulateThisValue2 = null) + { + var assertionBuilder = valueSource.RegisterAssertion(new IsCloseToCondition(expected, precision) + , [doNotPopulateThisValue1, doNotPopulateThisValue2]); + + return new IsCloseToWrapper(assertionBuilder); + } +} + +public class IsCloseToWrapper(InvokableAssertionBuilder invokableAssertionBuilder) + : InvokableValueAssertionBuilder(invokableAssertionBuilder); + +file class IsCloseToCondition(TActual expected, TActual tolerance) : BaseAssertCondition + where TActual : + IFloatingPoint, + INumberBase +{ + protected override string GetExpectation() => $"to be within {tolerance} of {expected}"; + + protected override ValueTask GetResult( + TActual? actualValue, Exception? exception, + AssertionMetadata assertionMetadata + ) + { + if(actualValue is null) + return AssertionResult.Fail("received null"); + + TActual difference = actualValue - expected; + TActual absoluteDifference = TActual.Abs(difference); + bool isInRange = absoluteDifference <= tolerance; + return AssertionResult.FailIf(!isInRange, $"received {actualValue}"); + } +} diff --git a/tests/MaterialDesignThemes.UITests/TestBase.cs b/tests/MaterialDesignThemes.UITests/TestBase.cs index 66615f971c..e2aeac2535 100644 --- a/tests/MaterialDesignThemes.UITests/TestBase.cs +++ b/tests/MaterialDesignThemes.UITests/TestBase.cs @@ -1,7 +1,10 @@ using System.Diagnostics.CodeAnalysis; using System.Windows.Media; +using MaterialDesignThemes.UITests; +using TUnit.Core.Interfaces; + +[assembly: ParallelLimiter] -[assembly: CollectionBehavior(DisableTestParallelization = true)] [assembly: GenerateHelpers(typeof(AutoSuggestBox))] [assembly: GenerateHelpers(typeof(ColorPicker))] [assembly: GenerateHelpers(typeof(DecimalUpDown))] @@ -16,10 +19,15 @@ namespace MaterialDesignThemes.UITests; -public abstract class TestBase(ITestOutputHelper output) : IAsyncLifetime +public record SingleParallelLimit : IParallelLimit +{ + public int Limit => 1; +} + +public abstract class TestBase() { protected bool AttachedDebuggerToRemoteProcess { get; set; } = true; - protected ITestOutputHelper Output { get; } = output ?? throw new ArgumentNullException(nameof(output)); + protected static TextWriter Output => TestContext.Current?.OutputWriter ?? throw new InvalidOperationException("Could not find output writer"); [NotNull] protected IApp? App { get; set; } @@ -46,7 +54,8 @@ protected async Task LoadUserControl(Type userControlType) return await App.CreateWindowWithUserControl(userControlType); } - public async Task InitializeAsync() => + [Before(Test)] + public async ValueTask InitializeAsync() => App = await XamlTest.App.StartRemote(new AppOptions { #if !DEBUG @@ -55,5 +64,7 @@ public async Task InitializeAsync() => AllowVisualStudioDebuggerAttach = AttachedDebuggerToRemoteProcess, LogMessage = Output.WriteLine }); - public async Task DisposeAsync() => await App.DisposeAsync(); + + [After(Test)] + public async ValueTask DisposeAsync() => await App.DisposeAsync(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs index 5d4c7494c6..f1302b56bf 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs @@ -1,20 +1,17 @@ -using System.Collections; using System.ComponentModel; using MaterialDesignThemes.UITests.Samples.AutoSuggestBoxes; using MaterialDesignThemes.UITests.Samples.AutoSuggestTextBoxes; -using Xunit.Sdk; - +using TUnit.Core.Exceptions; namespace MaterialDesignThemes.UITests.WPF.AutoSuggestBoxes; public class AutoSuggestBoxTests : TestBase { - public AutoSuggestBoxTests(ITestOutputHelper output) - : base(output) + public AutoSuggestBoxTests() { - AttachedDebuggerToRemoteProcess = true; + AttachedDebuggerToRemoteProcess = false; } - [Fact] + [Test] public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggestions() { await using var recorder = new TestRecorder(App); @@ -30,8 +27,8 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti //Assert - Assert.True(await suggestBox.GetIsSuggestionOpen()); - Assert.True(await popup.GetIsOpen()); + await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue(); + await Assert.That(await popup.GetIsOpen()).IsTrue(); //Validates these elements are found await AssertExists(suggestionListBox, "Bananas"); @@ -45,7 +42,7 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti recorder.Success(); } - [Fact] + [Test] public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated() { await using var recorder = new TestRecorder(App); @@ -60,8 +57,8 @@ public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated() await suggestBox.SendInput(new KeyboardInput("B")); //Assert - Assert.True(await suggestBox.GetIsSuggestionOpen()); - Assert.True(await popup.GetIsOpen()); + await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue(); + await Assert.That(await popup.GetIsOpen()).IsTrue(); double? lastHeight = null; await Wait.For(async () => @@ -72,7 +69,7 @@ await Wait.For(async () => lastHeight = currentHeight; if (!rv) { - await Task.Delay(100); + await Task.Delay(100, TestContext.Current!.CancellationToken); } return rv; }); @@ -83,16 +80,16 @@ await Wait.For(async () => await bananas.LeftClick(); // Wait for the text to be updated - await Task.Delay(50); + await Task.Delay(50, TestContext.Current!.CancellationToken); var suggestBoxText = await suggestBox.GetText(); //Validate that the current text is the same as the selected item - Assert.Equal("Bananas", suggestBoxText); + await Assert.That(suggestBoxText).IsEqualTo("Bananas"); recorder.Success(); } - [Fact] + [Test] public async Task CanFilterItems_WithCollectionView_FiltersSuggestions() { await using var recorder = new TestRecorder(App); @@ -109,8 +106,8 @@ public async Task CanFilterItems_WithCollectionView_FiltersSuggestions() //Assert - Assert.True(await suggestBox.GetIsSuggestionOpen()); - Assert.True(await popup.GetIsOpen()); + await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue(); + await Assert.That(await popup.GetIsOpen()).IsTrue(); //Validates these elements are found await AssertExists(suggestionListBox, "Bananas"); @@ -124,7 +121,7 @@ public async Task CanFilterItems_WithCollectionView_FiltersSuggestions() recorder.Success(); } - [Fact] + [Test] [Description("Issue 3761")] public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed() { @@ -145,22 +142,22 @@ public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed() // Act await suggestBox.MoveKeyboardFocus(); - await Task.Delay(50); + await Task.Delay(50, TestContext.Current!.CancellationToken); await suggestBox.SendInput(new KeyboardInput("B")); // Open the popup - await Task.Delay(50); + await Task.Delay(50, TestContext.Current.CancellationToken); await suggestBox.SendInput(new KeyboardInput(Key.Escape)); // Close the popup - await Task.Delay(50); + await Task.Delay(50, TestContext.Current.CancellationToken); await suggestBox.SendInput(new KeyboardInput(Key.Tab)); // Press TAB to focus the next element - await Task.Delay(50); + await Task.Delay(50, TestContext.Current.CancellationToken); // Assert - Assert.False(await suggestBox.GetIsFocused()); - Assert.True(await nextTextBox.GetIsFocused()); + await Assert.That(await suggestBox.GetIsFocused()).IsFalse(); + await Assert.That(await nextTextBox.GetIsFocused()).IsTrue(); recorder.Success(); } - [Fact] + [Test] [Description("Issue 3815")] public async Task AutoSuggestBox_KeysUpAndDown_WrapAround() { @@ -176,7 +173,7 @@ public async Task AutoSuggestBox_KeysUpAndDown_WrapAround() //Act & Assert await suggestBox.MoveKeyboardFocus(); await suggestBox.SendInput(new KeyboardInput("e")); - await Task.Delay(delay); + await Task.Delay(delay, TestContext.Current!.CancellationToken); static int? GetSuggestionCount(AutoSuggestBox autoSuggestBox) { @@ -188,17 +185,51 @@ public async Task AutoSuggestBox_KeysUpAndDown_WrapAround() //Assert that initially the first item is selected int selectedIndex = await suggestionListBox.GetSelectedIndex(); - Assert.Equal(0, selectedIndex); - await Task.Delay(delay); + await Assert.That(selectedIndex).IsEqualTo(0); + await Task.Delay(delay, TestContext.Current.CancellationToken); //Assert that the last item is selected after pressing ArrowUp await suggestBox.SendInput(new KeyboardInput(Key.Up)); - Assert.Equal(itemCount - 1, await suggestionListBox.GetSelectedIndex()); - await Task.Delay(delay); + await Assert.That(await suggestionListBox.GetSelectedIndex()).IsEqualTo(itemCount - 1); + await Task.Delay(delay, TestContext.Current.CancellationToken); //Assert that the first item is selected after pressing ArrowDown await suggestBox.SendInput(new KeyboardInput(Key.Down)); - Assert.Equal(0, await suggestionListBox.GetSelectedIndex()); + await Assert.That(await suggestionListBox.GetSelectedIndex()).IsEqualTo(0); + + recorder.Success(); + } + + [Test] + [Description("Issue 3845")] + public async Task AutoSuggestBox_SelectingAnItem_SetsSelectedItem() + { + await using var recorder = new TestRecorder(App); + + //Arrange + IVisualElement userControl = await LoadUserControl(); + IVisualElement suggestBox = await userControl.GetElement(); + IVisualElement popup = await suggestBox.GetElement(); + IVisualElement suggestionListBox = await popup.GetElement(); + + //Act + await suggestBox.MoveKeyboardFocus(); + await Task.Delay(50); + await suggestBox.SendKeyboardInput($"B{Key.Down}{Key.Enter}"); + await Task.Delay(50); + + //Assert + string? selectedItem = (await suggestBox.GetSelectedItem()) as string; + await Assert.That(selectedItem).IsEqualTo("Bananas"); + + static async Task AssertViewModelProperty(AutoSuggestBox autoSuggestBox) + { + var viewModel = (AutoSuggestTextBoxWithCollectionViewViewModel)autoSuggestBox.DataContext; + await Assert.That(viewModel.SelectedItem).IsEqualTo("Bananas"); + } + await suggestBox.RemoteExecute(AssertViewModelProperty); + + recorder.Success(); } private static async Task AssertExists(IVisualElement suggestionListBox, string text, bool existsOrNotCheck = true) @@ -206,11 +237,11 @@ private static async Task AssertExists(IVisualElement suggestionListBox try { _ = await suggestionListBox.GetElement(ElementQuery.PropertyExpression(x => x.Text, text)); - Assert.True(existsOrNotCheck); + await Assert.That(existsOrNotCheck).IsTrue(); } - catch (Exception e) when (e is not TrueException) + catch (Exception e) when (e is not TUnitException) { - Assert.False(existsOrNotCheck); + await Assert.That(existsOrNotCheck).IsFalse(); } } } diff --git a/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs index 1718fcc834..312ab51d28 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs @@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Buttons; public class OutlineButtonTests : TestBase { - public OutlineButtonTests(ITestOutputHelper output) - : base(output) - { } - - [Fact] + [Test] public async Task OutlinedButton_UsesThemeColorForBorder() { await using var recorder = new TestRecorder(App); @@ -24,13 +20,13 @@ public async Task OutlinedButton_UsesThemeColorForBorder() Color? internalBorderColor = await internalBorder.GetBorderBrushColor(); //Assert - Assert.Equal(midColor, borderColor); - Assert.Equal(midColor, internalBorderColor); + await Assert.That(borderColor).IsEqualTo(midColor); + await Assert.That(internalBorderColor).IsEqualTo(midColor); recorder.Success(); } - [Fact] + [Test] public async Task OutlinedButton_BorderCanBeOverridden() { await using var recorder = new TestRecorder(App); @@ -50,13 +46,13 @@ public async Task OutlinedButton_BorderCanBeOverridden() Color? borderBrush = await internalBorder.GetBorderBrushColor(); //Assert - Assert.Equal(new Thickness(5), borderThickness); - Assert.Equal(Colors.Red, borderBrush); + await Assert.That(borderThickness).IsEqualTo(new Thickness(5)); + await Assert.That(borderBrush).IsEqualTo(Colors.Red); recorder.Success(); } - [Fact] + [Test] public async Task OutlinedButton_OnMouseOver_UsesThemeBrush() { await using var recorder = new TestRecorder(App); @@ -74,7 +70,7 @@ await Wait.For(async () => SolidColorBrush? internalBorderBackground = (await internalBorder.GetBackground()) as SolidColorBrush; //Assert - Assert.Equal(midColor, internalBorderBackground?.Color); + await Assert.That(internalBorderBackground?.Color).IsEqualTo(midColor); }); recorder.Success(); diff --git a/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs index c0ed522aec..39c7b3ea7a 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs @@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Buttons; public class RaisedButtonTests : TestBase { - public RaisedButtonTests(ITestOutputHelper output) - : base(output) - { } - - [Fact] + [Test] public async Task OnLoad_ThemeBrushesSet() { await using var recorder = new TestRecorder(App); @@ -21,7 +17,7 @@ public async Task OnLoad_ThemeBrushesSet() Color? color = await button.GetBackgroundColor(); //Assert - Assert.Equal(midColor, color); + await Assert.That(color).IsEqualTo(midColor); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs index f30f158a9e..1187395aee 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs @@ -1,12 +1,11 @@ -namespace MaterialDesignThemes.UITests.WPF.Cards; + + +namespace MaterialDesignThemes.UITests.WPF.Cards; public class ElevatedCardTests : TestBase { - public ElevatedCardTests(ITestOutputHelper output) - : base(output) - { } - [Fact] + [Test] public async Task ElevatedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnBorder() { await using var recorder = new TestRecorder(App); @@ -20,10 +19,10 @@ public async Task ElevatedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnB CornerRadius? internalBorderCornerRadius = await internalBorder.GetCornerRadius(); //Assert - Assert.Equal(5, internalBorderCornerRadius.Value.TopLeft); - Assert.Equal(5, internalBorderCornerRadius.Value.TopRight); - Assert.Equal(5, internalBorderCornerRadius.Value.BottomRight); - Assert.Equal(5, internalBorderCornerRadius.Value.BottomLeft); + await Assert.That(internalBorderCornerRadius.Value.TopLeft).IsEqualTo(5); + await Assert.That(internalBorderCornerRadius.Value.TopRight).IsEqualTo(5); + await Assert.That(internalBorderCornerRadius.Value.BottomRight).IsEqualTo(5); + await Assert.That(internalBorderCornerRadius.Value.BottomLeft).IsEqualTo(5); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs index 424cbaf138..15da509acc 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs @@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Cards; public class OutlinedCardTests : TestBase { - public OutlinedCardTests(ITestOutputHelper output) - : base(output) - { } - - [Fact] + [Test] public async Task OutlinedCard_UsesThemeColorForBorder() { await using var recorder = new TestRecorder(App); @@ -23,12 +19,12 @@ public async Task OutlinedCard_UsesThemeColorForBorder() Color? internalBorderColor = await internalBorder.GetBorderBrushColor(); //Assert - Assert.Equal(dividerColor, internalBorderColor); + await Assert.That(internalBorderColor).IsEqualTo(dividerColor); recorder.Success(); } - [Fact] + [Test] public async Task OutlinedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnBorder() { await using var recorder = new TestRecorder(App); @@ -42,10 +38,10 @@ public async Task OutlinedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnB CornerRadius? internalBorderCornerRadius = await internalBorder.GetCornerRadius(); //Assert - Assert.Equal(5, internalBorderCornerRadius.Value.TopLeft); - Assert.Equal(5, internalBorderCornerRadius.Value.TopRight); - Assert.Equal(5, internalBorderCornerRadius.Value.BottomRight); - Assert.Equal(5, internalBorderCornerRadius.Value.BottomLeft); + await Assert.That(internalBorderCornerRadius.Value.TopLeft).IsEqualTo(5); + await Assert.That(internalBorderCornerRadius.Value.TopRight).IsEqualTo(5); + await Assert.That(internalBorderCornerRadius.Value.BottomRight).IsEqualTo(5); + await Assert.That(internalBorderCornerRadius.Value.BottomLeft).IsEqualTo(5); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs index 57805e8a1c..922a0b5cd8 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs @@ -5,12 +5,7 @@ namespace MaterialDesignThemes.UITests.WPF; public class ColorPickerTests : TestBase { - public ColorPickerTests(ITestOutputHelper output) - : base(output) - { - } - - [Fact] + [Test] public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday() { await using var recorder = new TestRecorder(App); @@ -29,12 +24,12 @@ public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday() await thumb.SendInput(MouseInput.MoveRelative(xOffset: -5, yOffset: -10)); await thumb.SendInput(MouseInput.LeftDown()); await thumb.SendInput(MouseInput.MoveRelative(yOffset: 25)); - await Task.Delay(100); + await Task.Delay(100, TestContext.Current!.CancellationToken); await thumb.SendInput(MouseInput.LeftUp()); double currentBrightness = (await colorPicker.GetColor()).ToHsb().Brightness; - Assert.True(currentBrightness < lastBrightness, $"Brightness {currentBrightness} is not less than {lastBrightness}"); + await Assert.That(currentBrightness).IsLessThan(lastBrightness); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs index 6422947496..bc8dca69ca 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs @@ -1,26 +1,21 @@ using System.Windows.Media; + namespace MaterialDesignThemes.UITests.WPF.ColorZones; public class ColorZoneTests : TestBase { - public ColorZoneTests(ITestOutputHelper output) - : base(output) - { - - } - - [Theory] - [InlineData(ColorZoneMode.Standard, "MaterialDesign.Brush.Background", "MaterialDesign.Brush.Foreground")] - [InlineData(ColorZoneMode.Inverted, "MaterialDesign.Brush.Foreground", "MaterialDesign.Brush.Background")] - [InlineData(ColorZoneMode.PrimaryLight, "MaterialDesign.Brush.Primary.Light", "MaterialDesign.Brush.Primary.Light.Foreground")] - [InlineData(ColorZoneMode.PrimaryMid, "MaterialDesign.Brush.Primary", "MaterialDesign.Brush.Primary.Foreground")] - [InlineData(ColorZoneMode.PrimaryDark, "MaterialDesign.Brush.Primary.Dark", "MaterialDesign.Brush.Primary.Dark.Foreground")] - [InlineData(ColorZoneMode.SecondaryLight, "MaterialDesign.Brush.Secondary.Light", "MaterialDesign.Brush.Secondary.Light.Foreground")] - [InlineData(ColorZoneMode.SecondaryMid, "MaterialDesign.Brush.Secondary", "MaterialDesign.Brush.Secondary.Foreground")] - [InlineData(ColorZoneMode.SecondaryDark, "MaterialDesign.Brush.Secondary.Dark", "MaterialDesign.Brush.Secondary.Dark.Foreground")] - [InlineData(ColorZoneMode.Light, "MaterialDesign.Brush.ColorZone.LightBackground", "MaterialDesign.Brush.ColorZone.LightForeground")] - [InlineData(ColorZoneMode.Dark, "MaterialDesign.Brush.ColorZone.DarkBackground", "MaterialDesign.Brush.ColorZone.DarkForeground")] + [Test] + [Arguments(ColorZoneMode.Standard, "MaterialDesign.Brush.Background", "MaterialDesign.Brush.Foreground")] + [Arguments(ColorZoneMode.Inverted, "MaterialDesign.Brush.Foreground", "MaterialDesign.Brush.Background")] + [Arguments(ColorZoneMode.PrimaryLight, "MaterialDesign.Brush.Primary.Light", "MaterialDesign.Brush.Primary.Light.Foreground")] + [Arguments(ColorZoneMode.PrimaryMid, "MaterialDesign.Brush.Primary", "MaterialDesign.Brush.Primary.Foreground")] + [Arguments(ColorZoneMode.PrimaryDark, "MaterialDesign.Brush.Primary.Dark", "MaterialDesign.Brush.Primary.Dark.Foreground")] + [Arguments(ColorZoneMode.SecondaryLight, "MaterialDesign.Brush.Secondary.Light", "MaterialDesign.Brush.Secondary.Light.Foreground")] + [Arguments(ColorZoneMode.SecondaryMid, "MaterialDesign.Brush.Secondary", "MaterialDesign.Brush.Secondary.Foreground")] + [Arguments(ColorZoneMode.SecondaryDark, "MaterialDesign.Brush.Secondary.Dark", "MaterialDesign.Brush.Secondary.Dark.Foreground")] + [Arguments(ColorZoneMode.Light, "MaterialDesign.Brush.ColorZone.LightBackground", "MaterialDesign.Brush.ColorZone.LightForeground")] + [Arguments(ColorZoneMode.Dark, "MaterialDesign.Brush.ColorZone.DarkBackground", "MaterialDesign.Brush.ColorZone.DarkForeground")] public async Task Mode_SetsThemeColors(ColorZoneMode mode, string backgroundBrush, string foregroundBrush) { await using var recorder = new TestRecorder(App); @@ -31,8 +26,8 @@ public async Task Mode_SetsThemeColors(ColorZoneMode mode, string backgroundBrus Color background = await GetThemeColor(backgroundBrush); Color foreground = await GetThemeColor(foregroundBrush); - Assert.Equal(background, await colorZone.GetBackgroundColor()); - Assert.Equal(foreground, await colorZone.GetForegroundColor()); + await Assert.That(await colorZone.GetBackgroundColor()).IsEqualTo(background); + await Assert.That(await colorZone.GetForegroundColor()).IsEqualTo(foreground); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs index d081596312..1510cf2b05 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs @@ -5,12 +5,7 @@ namespace MaterialDesignThemes.UITests.WPF.ComboBoxes; public class ComboBoxTests : TestBase { - public ComboBoxTests(ITestOutputHelper output) - : base(output) - { - } - - [Fact] + [Test] [Description("Pull Request 2192")] public async Task OnComboBoxHelperTextFontSize_ChangesHelperTextFontSize() { @@ -26,11 +21,11 @@ public async Task OnComboBoxHelperTextFontSize_ChangesHelperTextFontSize() double fontSize = await helpTextBlock.GetFontSize(); - Assert.Equal(20, fontSize); + await Assert.That(fontSize).IsEqualTo(20); recorder.Success(); } - [Fact] + [Test] [Description("Pull Request 2192")] public async Task OnFilledComboBoxHelperTextFontSize_ChangesHelperTextFontSize() { @@ -47,11 +42,11 @@ public async Task OnFilledComboBoxHelperTextFontSize_ChangesHelperTextFontSize() double fontSize = await helpTextBlock.GetFontSize(); - Assert.Equal(20, fontSize); + await Assert.That(fontSize).IsEqualTo(20); recorder.Success(); } - [Fact] + [Test] [Description("Issue 2495")] public async Task OnComboBox_WithClearButton_ClearsSelection() { @@ -74,23 +69,23 @@ public async Task OnComboBox_WithClearButton_ClearsSelection() int? selectedIndex = await comboBox.GetSelectedIndex(); object? text = await comboBox.GetText(); - Assert.True(selectedIndex >= 0); - Assert.NotNull(text); + await Assert.That(selectedIndex >= 0).IsTrue(); + await Assert.That(text).IsNotNull(); await clearButton.LeftClick(); await Wait.For(async () => { text = await comboBox.GetText(); - Assert.Null(text); + await Assert.That(text).IsNull(); selectedIndex = await comboBox.GetSelectedIndex(); - Assert.False(selectedIndex >= 0); + await Assert.That(selectedIndex >= 0).IsFalse(); }); recorder.Success(); } - [Fact] + [Test] [Description("Issue 2690")] public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste() { @@ -108,7 +103,7 @@ public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste() await comboBox.RightClick(); IVisualElement? contextMenu = await comboBox.GetContextMenu(); - Assert.True(contextMenu is not null, "No context menu set on the ComboBox"); + await Assert.That(contextMenu).IsNotNull().Because("No context menu set on the ComboBox"); await Wait.For(async () => await contextMenu!.GetIsVisible()); await AssertMenu("Cut"); await AssertMenu("Copy"); @@ -119,11 +114,11 @@ public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste() async Task AssertMenu(string menuHeader) { var menuItem = await contextMenu!.GetElement(ElementQuery.PropertyExpression(x => x.Header, menuHeader)); - Assert.True(menuItem is not null, $"{menuHeader} menu item not found"); + await Assert.That(menuItem).IsNotNull().Because($"{menuHeader} menu item not found"); } } - [Fact] + [Test] [Description("Issue 2713")] public async Task OnEditableComboBox_ClickInTextArea_FocusesTextBox() { @@ -147,7 +142,7 @@ public async Task OnEditableComboBox_ClickInTextArea_FocusesTextBox() // Open the ComboBox initially await comboBox.LeftClick(Position.RightCenter); - await Task.Delay(50); // Allow a little time for the drop-down to open (and property to change) + await Task.Delay(50, TestContext.Current!.CancellationToken); // Allow a little time for the drop-down to open (and property to change) bool wasOpenAfterClickOnToggleButton = await comboBox.GetIsDropDownOpen(); // Focus (i.e. click) another element @@ -155,29 +150,29 @@ public async Task OnEditableComboBox_ClickInTextArea_FocusesTextBox() // Click the editable TextBox of the ComboBox await editableTextBox.LeftClick(); - await Task.Delay(50); // Allow a little time for the drop-down to open (and property to change) + await Task.Delay(50, TestContext.Current.CancellationToken); // Allow a little time for the drop-down to open (and property to change) bool wasOpenAfterClickOnEditableTextBox = await comboBox.GetIsDropDownOpen(); bool textBoxHasFocus = await editableTextBox.GetIsFocused(); bool textBoxHasKeyboardFocus = await editableTextBox.GetIsKeyboardFocused(); - Assert.True(wasOpenAfterClickOnToggleButton, "ComboBox should have opened drop down when clicking the toggle button"); - Assert.False(wasOpenAfterClickOnEditableTextBox, "ComboBox should not have opened drop down when clicking the editable TextBox"); - Assert.True(textBoxHasFocus, "Editable TextBox should have focus"); - Assert.True(textBoxHasKeyboardFocus, "Editable TextBox should have keyboard focus"); + await Assert.That(wasOpenAfterClickOnToggleButton).IsTrue().Because("ComboBox should have opened drop down when clicking the toggle button"); + await Assert.That(wasOpenAfterClickOnEditableTextBox).IsFalse().Because("ComboBox should not have opened drop down when clicking the editable ait wTextBox"); + await Assert.That(textBoxHasFocus).IsTrue().Because("Editable TextBox should have focus"); + await Assert.That(textBoxHasKeyboardFocus).IsTrue().Because("Editable TextBox should have keyboard focus"); recorder.Success(); } - [Theory] - [InlineData("MaterialDesignFloatingHintComboBox", null)] - [InlineData("MaterialDesignFloatingHintComboBox", 5)] - [InlineData("MaterialDesignFloatingHintComboBox", 20)] - [InlineData("MaterialDesignFilledComboBox", null)] - [InlineData("MaterialDesignFilledComboBox", 5)] - [InlineData("MaterialDesignFilledComboBox", 20)] - [InlineData("MaterialDesignOutlinedComboBox", null)] - [InlineData("MaterialDesignOutlinedComboBox", 5)] - [InlineData("MaterialDesignOutlinedComboBox", 20)] + [Test] + [Arguments("MaterialDesignFloatingHintComboBox", null)] + [Arguments("MaterialDesignFloatingHintComboBox", 5)] + [Arguments("MaterialDesignFloatingHintComboBox", 20)] + [Arguments("MaterialDesignFilledComboBox", null)] + [Arguments("MaterialDesignFilledComboBox", 5)] + [Arguments("MaterialDesignFilledComboBox", 20)] + [Arguments("MaterialDesignOutlinedComboBox", null)] + [Arguments("MaterialDesignOutlinedComboBox", 5)] + [Arguments("MaterialDesignOutlinedComboBox", 20)] public async Task ComboBox_WithHintAndHelperText_RespectsPadding(string styleName, int? padding) { await using var recorder = new TestRecorder(App); @@ -203,22 +198,22 @@ public async Task ComboBox_WithHintAndHelperText_RespectsPadding(string styleNam Rect? hintCoordinates = await hint.GetCoordinates(); Rect? helperTextCoordinates = await helperText.GetCoordinates(); - Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left), 0, tolerance); - Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left), 0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsCloseTo(0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsCloseTo(0, tolerance); recorder.Success(); } - [Theory] - [InlineData("MaterialDesignFloatingHintComboBox", null)] - [InlineData("MaterialDesignFloatingHintComboBox", 5)] - [InlineData("MaterialDesignFloatingHintComboBox", 20)] - [InlineData("MaterialDesignFilledComboBox", null)] - [InlineData("MaterialDesignFilledComboBox", 5)] - [InlineData("MaterialDesignFilledComboBox", 20)] - [InlineData("MaterialDesignOutlinedComboBox", null)] - [InlineData("MaterialDesignOutlinedComboBox", 5)] - [InlineData("MaterialDesignOutlinedComboBox", 20)] + [Test] + [Arguments("MaterialDesignFloatingHintComboBox", null)] + [Arguments("MaterialDesignFloatingHintComboBox", 5)] + [Arguments("MaterialDesignFloatingHintComboBox", 20)] + [Arguments("MaterialDesignFilledComboBox", null)] + [Arguments("MaterialDesignFilledComboBox", 5)] + [Arguments("MaterialDesignFilledComboBox", 20)] + [Arguments("MaterialDesignOutlinedComboBox", null)] + [Arguments("MaterialDesignOutlinedComboBox", 5)] + [Arguments("MaterialDesignOutlinedComboBox", 20)] public async Task ComboBox_WithHintAndValidationError_RespectsPadding(string styleName, int? padding) { await using var recorder = new TestRecorder(App); @@ -252,17 +247,17 @@ public async Task ComboBox_WithHintAndValidationError_RespectsPadding(string sty Rect? hintCoordinates = await hint.GetCoordinates(); Rect? errorViewerCoordinates = await errorViewer.GetCoordinates(); - Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left), 0, tolerance); - Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left), 0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsCloseTo(0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsCloseTo(0, tolerance); recorder.Success(); } - [Theory] - [InlineData(HorizontalAlignment.Left)] - [InlineData(HorizontalAlignment.Right)] - [InlineData(HorizontalAlignment.Center)] - [InlineData(HorizontalAlignment.Stretch)] + [Test] + [Arguments(HorizontalAlignment.Left)] + [Arguments(HorizontalAlignment.Right)] + [Arguments(HorizontalAlignment.Center)] + [Arguments(HorizontalAlignment.Stretch)] [Description("Issue 3433")] public async Task ComboBox_WithHorizontalContentAlignment_RespectsAlignment(HorizontalAlignment alignment) { @@ -278,15 +273,15 @@ public async Task ComboBox_WithHorizontalContentAlignment_RespectsAlignment(Hori var comboBox = await stackPanel.GetElement("/ComboBox"); var selectedItemPresenter = await comboBox.GetElement("contentPresenter"); - Assert.Equal(alignment, await selectedItemPresenter.GetHorizontalAlignment()); + await Assert.That(await selectedItemPresenter.GetHorizontalAlignment()).IsEqualTo(alignment); recorder.Success(); } - [Theory] - [InlineData("MaterialDesignFloatingHintComboBox", 0, 0, 0, 1)] - [InlineData("MaterialDesignFilledComboBox", 0, 0, 0, 1)] - [InlineData("MaterialDesignOutlinedComboBox", 2, 2, 2, 2)] + [Test] + [Arguments("MaterialDesignFloatingHintComboBox", 0, 0, 0, 1)] + [Arguments("MaterialDesignFilledComboBox", 0, 0, 0, 1)] + [Arguments("MaterialDesignOutlinedComboBox", 2, 2, 2, 2)] [Description("Issue 3623")] public async Task ComboBox_BorderShouldDependOnAppliedStyle(string style, double left, double top, double right, double bottom) { @@ -305,7 +300,7 @@ public async Task ComboBox_BorderShouldDependOnAppliedStyle(string style, double await comboBox.LeftClick(); Thickness thickness = await border.GetBorderThickness(); - Assert.Equal(new Thickness(left, top, right, bottom), thickness); + await Assert.That(thickness).IsEqualTo(new Thickness(left, top, right, bottom)); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/ContentControls/ContentControlTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ContentControls/ContentControlTests.cs index b1e8b97c56..5350a69079 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/ContentControls/ContentControlTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/ContentControls/ContentControlTests.cs @@ -1,16 +1,11 @@ using System.ComponentModel; + namespace MaterialDesignThemes.UITests.WPF.ContentControls; public class ContentControlTests : TestBase { - public ContentControlTests(ITestOutputHelper output) - : base(output) - { - } - - - [Fact] + [Test] [Description("Issue 2510")] public async Task ClearButton_InsideOfControlTemplate_CanStillClearContent() { @@ -34,10 +29,10 @@ public async Task ClearButton_InsideOfControlTemplate_CanStillClearContent() await clearButton.LeftClick(); //Assert - Assert.Equal("Some Text", initial); + await Assert.That(initial).IsEqualTo("Some Text"); await Wait.For(async () => { - Assert.True(string.IsNullOrEmpty(await textBox.GetText())); + await Assert.That(await textBox.GetText()).IsNullOrEmpty(); }); recorder.Success(); diff --git a/tests/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs b/tests/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs index c4255d5c8d..f5a210c7b0 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs @@ -3,16 +3,12 @@ using System.Windows.Media; using MaterialDesignThemes.UITests.WPF.TextBoxes; + namespace MaterialDesignThemes.UITests.WPF.DatePickers; public class DatePickerTests : TestBase { - public DatePickerTests(ITestOutputHelper output) - : base(output) - { - } - - [Fact] + [Test] [Description("Pull Request 2192")] public async Task OnDatePickerHelperTextFontSize_ChangesHelperTextFontSize() { @@ -28,11 +24,11 @@ public async Task OnDatePickerHelperTextFontSize_ChangesHelperTextFontSize() double fontSize = await helpTextBlock.GetFontSize(); - Assert.Equal(20, fontSize); + await Assert.That(fontSize).IsEqualTo(20); recorder.Success(); } - [Fact] + [Test] [Description("Issue 2495")] public async Task OnDatePicker_WithClearButton_ClearsSelectedDate() { @@ -48,20 +44,20 @@ public async Task OnDatePicker_WithClearButton_ClearsSelectedDate() DateTime? selectedDate = await datePicker.GetSelectedDate(); - Assert.NotNull(selectedDate); + await Assert.That(selectedDate).IsNotNull(); await clearButton.LeftClick(); await Wait.For(async () => { selectedDate = await datePicker.GetSelectedDate(); - Assert.Null(selectedDate); + await Assert.That(selectedDate).IsNull(); }); recorder.Success(); } - [Fact] + [Test] [Description("Issue 3369")] public async Task OnDatePicker_WithClearButton_ClearsSelectedUncommittedText() { @@ -78,19 +74,19 @@ public async Task OnDatePicker_WithClearButton_ClearsSelectedUncommittedText() var clearButton = await datePicker.GetElement