From f9123cf0889c76247fc6070c2ce95573ce60ba64 Mon Sep 17 00:00:00 2001 From: Kevin Bost Date: Thu, 6 Mar 2025 21:46:08 -0800 Subject: [PATCH 01/28] Updating to xUnit v3 1.x --- Directory.packages.props | 11 ++++++----- .../MaterialDesignColors.Wpf.Tests.csproj | 11 +++++++++-- .../ResourceProviderFixture.cs | 2 +- .../MaterialDesignThemes.UITests.csproj | 4 ++-- tests/MaterialDesignThemes.UITests/TestBase.cs | 5 +++-- .../WPF/TreeListViews/TreeListViewTests.cs | 8 ++++---- .../MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs | 1 - .../EnumDataAttribute.cs | 10 ++++++---- .../MaterialDesignThemes.Wpf.Tests.csproj | 11 +++++++++-- 9 files changed, 40 insertions(+), 23 deletions(-) diff --git a/Directory.packages.props b/Directory.packages.props index 8fa27d2bfd..2fc556b771 100644 --- a/Directory.packages.props +++ b/Directory.packages.props @@ -1,9 +1,9 @@ - + - + @@ -24,11 +24,12 @@ + - - - + + + diff --git a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj index f2ab67fc5e..e4fd65ccce 100644 --- a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj +++ b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj @@ -4,6 +4,7 @@ net472;net8.0-windows MaterialDesignColors.Wpf.Tests MaterialDesignColors.Wpf.Tests + Exe @@ -25,9 +26,15 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + 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..80a410690a 100644 --- a/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs +++ b/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs @@ -1,7 +1,7 @@ using Shouldly; using Xunit; -namespace MaterialDesignColors.Wpf.Fixture; +namespace MaterialDesignColors.Wpf.Tests; public class ResourceProviderFixture { diff --git a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj index 2612cc5af3..138b7aac54 100644 --- a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj +++ b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj @@ -6,6 +6,7 @@ true $(NoWarn);CA1707 true + Exe @@ -19,18 +20,17 @@ - all runtime; build; native; contentfiles; analyzers; buildtransitive + - diff --git a/tests/MaterialDesignThemes.UITests/TestBase.cs b/tests/MaterialDesignThemes.UITests/TestBase.cs index 66615f971c..1a48415e54 100644 --- a/tests/MaterialDesignThemes.UITests/TestBase.cs +++ b/tests/MaterialDesignThemes.UITests/TestBase.cs @@ -46,7 +46,7 @@ protected async Task LoadUserControl(Type userControlType) return await App.CreateWindowWithUserControl(userControlType); } - public async Task InitializeAsync() => + public async ValueTask InitializeAsync() => App = await XamlTest.App.StartRemote(new AppOptions { #if !DEBUG @@ -55,5 +55,6 @@ public async Task InitializeAsync() => AllowVisualStudioDebuggerAttach = AttachedDebuggerToRemoteProcess, LogMessage = Output.WriteLine }); - public async Task DisposeAsync() => await App.DisposeAsync(); + + public async ValueTask DisposeAsync() => await App.DisposeAsync(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/TreeListViews/TreeListViewTests.cs b/tests/MaterialDesignThemes.UITests/WPF/TreeListViews/TreeListViewTests.cs index 4c7aba9f93..483f73bc83 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/TreeListViews/TreeListViewTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/TreeListViews/TreeListViewTests.cs @@ -862,7 +862,7 @@ public async Task TopLevelItemWithNestedExpandedChild_MovesChildrenMaintainingEx await item1.LeftClickExpander(); //NB: Needs to be long enough delay so the next click does not register as a double click - await Task.Delay(1000); + await Task.Delay(1000, TestContext.Current.CancellationToken); // Add children to item "1_1" and expand IVisualElement item11 = await treeListView.GetElement("/TreeListViewItem[3]"); @@ -870,16 +870,16 @@ public async Task TopLevelItemWithNestedExpandedChild_MovesChildrenMaintainingEx await item11.LeftClickExpander(); //NB: Needs to be long enough delay so the next click does not register as a double click - await Task.Delay(1000); + await Task.Delay(1000, TestContext.Current.CancellationToken); //Move parent item down await item1.LeftClick(); await upButton.LeftClick(); - await Task.Delay(1000); + await Task.Delay(1000, TestContext.Current.CancellationToken); await downButton.LeftClick(); - await Task.Delay(1000); + await Task.Delay(1000, TestContext.Current.CancellationToken); //Assert the child was successfully moved await AssertTreeItemContent(treeListView, 0, "0"); diff --git a/tests/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs b/tests/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs index cfc94767c2..b6cc44e812 100644 --- a/tests/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs +++ b/tests/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs @@ -1,7 +1,6 @@ using System.ComponentModel; using System.Threading; using System.Windows.Threading; -using Xunit; namespace MaterialDesignThemes.Wpf.Tests; diff --git a/tests/MaterialDesignThemes.Wpf.Tests/EnumDataAttribute.cs b/tests/MaterialDesignThemes.Wpf.Tests/EnumDataAttribute.cs index 1365affc42..dbaf54d660 100644 --- a/tests/MaterialDesignThemes.Wpf.Tests/EnumDataAttribute.cs +++ b/tests/MaterialDesignThemes.Wpf.Tests/EnumDataAttribute.cs @@ -1,11 +1,12 @@ using System.Reflection; using Xunit.Sdk; +using Xunit.v3; namespace MaterialDesignThemes.Wpf.Tests; public class EnumDataAttribute : DataAttribute { - public override IEnumerable GetData(MethodInfo testMethod) + public override ValueTask> GetData(MethodInfo testMethod, DisposalTracker disposalTracker) { ParameterInfo[] parameters = testMethod.GetParameters(); if (parameters.Length != 1 || @@ -14,14 +15,15 @@ public override IEnumerable GetData(MethodInfo testMethod) throw new Exception($"{testMethod.DeclaringType?.FullName}.{testMethod.Name} must have a single enum parameter"); } - return GetDataImplementation(parameters[0].ParameterType); + return new([..GetDataImplementation(parameters[0].ParameterType)]); - static IEnumerable GetDataImplementation(Type parameterType) + static IEnumerable GetDataImplementation(Type parameterType) { foreach (object enumValue in Enum.GetValues(parameterType).OfType()) { - yield return new[] { enumValue }; + yield return new TheoryDataRow(enumValue); } } } + public override bool SupportsDiscoveryEnumeration() => true; } diff --git a/tests/MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj b/tests/MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj index 788b56e8af..d56580b9b5 100644 --- a/tests/MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj +++ b/tests/MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj @@ -4,6 +4,8 @@ net472;net8.0-windows MaterialDesignThemes.Wpf.Tests MaterialDesignThemes.Wpf.Tests + Exe + true @@ -26,8 +28,13 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + From 86ee7bab7fdf48c67f0fc979ee6594fbc5bb74f0 Mon Sep 17 00:00:00 2001 From: Kevin Bost Date: Thu, 6 Mar 2025 21:51:35 -0800 Subject: [PATCH 02/28] Adding MTP https://devblogs.microsoft.com/dotnet/mtp-adoption-frameworks/ --- .../MaterialDesignColors.Wpf.Tests.csproj | 2 ++ .../MaterialDesignThemes.UITests.csproj | 2 ++ .../MaterialDesignThemes.Wpf.Tests.csproj | 2 ++ 3 files changed, 6 insertions(+) diff --git a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj index e4fd65ccce..aada8448a5 100644 --- a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj +++ b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj @@ -4,7 +4,9 @@ net472;net8.0-windows MaterialDesignColors.Wpf.Tests MaterialDesignColors.Wpf.Tests + true Exe + true diff --git a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj index 138b7aac54..1643fca400 100644 --- a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj +++ b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj @@ -6,7 +6,9 @@ true $(NoWarn);CA1707 true + true Exe + true diff --git a/tests/MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj b/tests/MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj index d56580b9b5..f6ec7580f7 100644 --- a/tests/MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj +++ b/tests/MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj @@ -4,7 +4,9 @@ net472;net8.0-windows MaterialDesignThemes.Wpf.Tests MaterialDesignThemes.Wpf.Tests + true Exe + true true From 35dd15d528ed95542f8e73e020cc98f4d7b2d325 Mon Sep 17 00:00:00 2001 From: Kevin Bost Date: Fri, 7 Mar 2025 00:16:39 -0800 Subject: [PATCH 03/28] Starting conversion to TUnit --- Directory.packages.props | 3 +- .../SwatchesProvider.cs | 18 +- .../ColorAssistTests.cs | 9 +- .../MaterialDesignColors.Wpf.Tests.csproj | 8 +- .../ResourceProviderFixture.cs | 41 ++- .../MaterialDesignThemes.UITests/AllStyles.cs | 63 ++-- .../MaterialDesignSpec.cs | 2 +- .../MaterialDesignThemes.UITests.csproj | 3 +- .../MaterialDesignThemes.UITests/TestBase.cs | 15 +- .../AutoSuggestTextBoxTests.cs | 45 +-- .../WPF/Buttons/OutlineButtonTests.cs | 20 +- .../WPF/Buttons/RaisedButtonTests.cs | 8 +- .../WPF/Cards/ElevatedCardTests.cs | 17 +- .../WPF/Cards/OutlinedCardTests.cs | 15 +- .../WPF/ColorPickerTests.cs | 5 +- .../WPF/ColorZones/ColorZoneTests.cs | 33 +- .../WPF/ComboBoxes/ComboBoxTests.cs | 109 ++++--- .../ContentControls/ContentControlTests.cs | 13 +- .../WPF/DatePickers/DatePickerTests.cs | 106 +++---- .../WPF/DialogHosts/DialogHostTests.cs | 113 +++---- .../WPF/DrawerHosts/DrawerHostTests.cs | 41 ++- .../WPF/Flippers/ClassicFlipperTests.cs | 24 +- .../WPF/ListBoxes/ListBoxTests.cs | 71 ++--- .../WPF/PasswordBoxes/PasswordBoxTests.cs | 151 ++++----- .../WPF/PopupBoxes/PopupBoxTests.cs | 17 +- .../WPF/SnackBars/SnackBarTests.cs | 7 +- .../WPF/SplitButtons/SplitButtonTests.cs | 31 +- .../WPF/TabControls/TabControlTests.cs | 41 +-- .../WPF/TextBoxes/TextBoxTests.cs | 151 ++++----- .../WPF/TextFieldDefaultHeightTests.cs | 50 +-- .../WPF/Theme/ColorAdjustTests.cs | 9 +- .../WPF/Theme/ThemeTests.cs | 15 +- .../WPF/Theme/ThemeTests.g.cs | 290 +++++++++--------- .../WPF/TimePickers/TimePickerTests.cs | 203 ++++++------ .../WPF/ToolBars/ToolBarTests.cs | 9 +- .../WPF/TreeListViews/TreeListViewTests.cs | 69 ++--- .../WPF/TreeViews/TreeViewTests.cs | 31 +- .../WPF/UpDownControls/DecimalUpDownTests.cs | 78 ++--- .../WPF/UpDownControls/NumericUpDownTests.cs | 79 ++--- 39 files changed, 982 insertions(+), 1031 deletions(-) diff --git a/Directory.packages.props b/Directory.packages.props index 2fc556b771..1e941f4061 100644 --- a/Directory.packages.props +++ b/Directory.packages.props @@ -26,10 +26,11 @@ + - + \ No newline at end of file diff --git a/src/MaterialDesignColors.Wpf/SwatchesProvider.cs b/src/MaterialDesignColors.Wpf/SwatchesProvider.cs index 81385d83bb..3caefa06bc 100644 --- a/src/MaterialDesignColors.Wpf/SwatchesProvider.cs +++ b/src/MaterialDesignColors.Wpf/SwatchesProvider.cs @@ -12,6 +12,7 @@ namespace MaterialDesignColors; /// public class SwatchesProvider { + private static readonly object _syncLock = new(); /// /// Generates an instance reading swatches from the provided assembly, allowing /// colours outside of the standard material palette to be loaded provided the are stored in the expected XAML format. @@ -39,12 +40,7 @@ public SwatchesProvider(Assembly assembly) Read(assemblyName, x.SingleOrDefault(y => y.match.Groups["type"].Value == "primary")?.key), Read(assemblyName, x.SingleOrDefault(y => y.match.Groups["type"].Value == "secondary")?.key) )) - .ToList() ?? -#if NETCOREAPP3_1_OR_GREATER - (IEnumerable)Array.Empty(); -#else - (IEnumerable)new Swatch[0]; -#endif + .ToList() ?? []; } /// @@ -98,8 +94,12 @@ static Hue GetHue(ResourceDictionary dictionary, DictionaryEntry entry) if (assemblyName is null || path is null) return null; - return (ResourceDictionary)Application.LoadComponent(new Uri( - $"/{assemblyName};component/{path.Replace(".baml", ".xaml")}", - UriKind.RelativeOrAbsolute)); + lock (_syncLock) + { + //NB: Application.LoadComponent is not thread safe + return (ResourceDictionary)Application.LoadComponent(new Uri( + $"/{assemblyName};component/{path.Replace(".baml", ".xaml")}", + UriKind.RelativeOrAbsolute)); + } } } 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 aada8448a5..079e511042 100644 --- a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj +++ b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj @@ -31,12 +31,6 @@ - - - - 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 80a410690a..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.Tests; +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..a81522764d 100644 --- a/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs +++ b/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs @@ -22,6 +22,6 @@ public static void AssertContrastRatio(Color foreground, Color background, doubl 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"); + await Assert.True(ratio >= minimumContrastRatio - tolerance, $"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 1643fca400..5a024dcc60 100644 --- a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj +++ b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj @@ -26,13 +26,12 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - diff --git a/tests/MaterialDesignThemes.UITests/TestBase.cs b/tests/MaterialDesignThemes.UITests/TestBase.cs index 1a48415e54..14afe0ef5d 100644 --- a/tests/MaterialDesignThemes.UITests/TestBase.cs +++ b/tests/MaterialDesignThemes.UITests/TestBase.cs @@ -1,7 +1,9 @@ using System.Diagnostics.CodeAnalysis; using System.Windows.Media; +using MaterialDesignThemes.UITests; +using TUnit.Core.Interfaces; -[assembly: CollectionBehavior(DisableTestParallelization = true)] +[assembly: ParallelLimiter] [assembly: GenerateHelpers(typeof(AutoSuggestBox))] [assembly: GenerateHelpers(typeof(ColorPicker))] [assembly: GenerateHelpers(typeof(DecimalUpDown))] @@ -16,10 +18,15 @@ namespace MaterialDesignThemes.UITests; -public abstract class TestBase(ITestOutputHelper output) : IAsyncLifetime +file 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 TextWriter Output => TestContext.Current?.OutputWriter ?? throw new InvalidOperationException("Could not find output writer"); [NotNull] protected IApp? App { get; set; } @@ -46,6 +53,7 @@ protected async Task LoadUserControl(Type userControlType) return await App.CreateWindowWithUserControl(userControlType); } + [Before(Test)] public async ValueTask InitializeAsync() => App = await XamlTest.App.StartRemote(new AppOptions { @@ -56,5 +64,6 @@ public async ValueTask InitializeAsync() => LogMessage = Output.WriteLine }); + [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 59e2fc3f75..032e2e2e4c 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs @@ -1,19 +1,11 @@ using System.ComponentModel; using MaterialDesignThemes.UITests.Samples.AutoSuggestBoxes; using MaterialDesignThemes.UITests.Samples.AutoSuggestTextBoxes; -using Xunit.Sdk; - namespace MaterialDesignThemes.UITests.WPF.AutoSuggestBoxes; public class AutoSuggestBoxTests : TestBase { - public AutoSuggestBoxTests(ITestOutputHelper output) - : base(output) - { - AttachedDebuggerToRemoteProcess = true; - } - - [Fact] + [Test] public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggestions() { await using var recorder = new TestRecorder(App); @@ -29,8 +21,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"); @@ -44,7 +36,7 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti recorder.Success(); } - [Fact] + [Test] public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated() { await using var recorder = new TestRecorder(App); @@ -59,8 +51,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 () => @@ -86,12 +78,12 @@ await Wait.For(async () => 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); @@ -108,8 +100,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"); @@ -123,7 +115,7 @@ public async Task CanFilterItems_WithCollectionView_FiltersSuggestions() recorder.Success(); } - [Fact] + [Test] [Description("Issue 3761")] public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed() { @@ -153,8 +145,8 @@ public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed() await Task.Delay(50); // 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(); } @@ -234,14 +226,7 @@ static void AssertViewModelProperty(AutoSuggestBox autoSuggestBox) private static async Task AssertExists(IVisualElement suggestionListBox, string text, bool existsOrNotCheck = true) { - try - { - _ = await suggestionListBox.GetElement(ElementQuery.PropertyExpression(x => x.Text, text)); - Assert.True(existsOrNotCheck); - } - catch (Exception e) when (e is not TrueException) - { - Assert.False(existsOrNotCheck); - } + _ = await suggestionListBox.GetElement(ElementQuery.PropertyExpression(x => x.Text, text)); + await Assert.That(existsOrNotCheck).IsTrue(); } } 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..a811694067 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs @@ -1,5 +1,6 @@ using System.Windows.Media; + namespace MaterialDesignThemes.UITests.WPF.Cards; public class OutlinedCardTests : TestBase @@ -8,7 +9,7 @@ public OutlinedCardTests(ITestOutputHelper output) : base(output) { } - [Fact] + [Test] public async Task OutlinedCard_UsesThemeColorForBorder() { await using var recorder = new TestRecorder(App); @@ -23,12 +24,12 @@ public async Task OutlinedCard_UsesThemeColorForBorder() Color? internalBorderColor = await internalBorder.GetBorderBrushColor(); //Assert - Assert.Equal(dividerColor, internalBorderColor); + await Assert.Equal(dividerColor, internalBorderColor); recorder.Success(); } - [Fact] + [Test] public async Task OutlinedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnBorder() { await using var recorder = new TestRecorder(App); @@ -42,10 +43,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.Equal(5, internalBorderCornerRadius.Value.TopLeft); + await Assert.Equal(5, internalBorderCornerRadius.Value.TopRight); + await Assert.Equal(5, internalBorderCornerRadius.Value.BottomRight); + await Assert.Equal(5, internalBorderCornerRadius.Value.BottomLeft); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs index 57805e8a1c..c81fc08918 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs @@ -1,6 +1,7 @@ using System.Windows.Media; using MaterialDesignColors.ColorManipulation; + namespace MaterialDesignThemes.UITests.WPF; public class ColorPickerTests : TestBase @@ -10,7 +11,7 @@ public ColorPickerTests(ITestOutputHelper output) { } - [Fact] + [Test] public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday() { await using var recorder = new TestRecorder(App); @@ -34,7 +35,7 @@ public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday() double currentBrightness = (await colorPicker.GetColor()).ToHsb().Brightness; - Assert.True(currentBrightness < lastBrightness, $"Brightness {currentBrightness} is not less than {lastBrightness}"); + await Assert.True(currentBrightness < lastBrightness, $"Brightness {currentBrightness} is not less than {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..299581a4dc 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).IsNotNull(); 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() { @@ -160,24 +155,24 @@ public async Task OnEditableComboBox_ClickInTextArea_FocusesTextBox() 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)).IsBetween(-tolerance, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsBetween(-tolerance, 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)).IsBetween(-tolerance, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsBetween(-tolerance, 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..e9c4615b32 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).IsNull(); 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 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); - await 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 5a024dcc60..53a2cc6ebe 100644 --- a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj +++ b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj @@ -31,6 +31,7 @@ + diff --git a/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs b/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs new file mode 100644 index 0000000000..766d164954 --- /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.UITests.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 14afe0ef5d..6622a544e3 100644 --- a/tests/MaterialDesignThemes.UITests/TestBase.cs +++ b/tests/MaterialDesignThemes.UITests/TestBase.cs @@ -18,7 +18,7 @@ namespace MaterialDesignThemes.UITests; -file record SingleParallelLimit : IParallelLimit +public record SingleParallelLimit : IParallelLimit { public int Limit => 1; } @@ -26,7 +26,7 @@ namespace MaterialDesignThemes.UITests; public abstract class TestBase() { protected bool AttachedDebuggerToRemoteProcess { get; set; } = true; - protected TextWriter Output => TestContext.Current?.OutputWriter ?? throw new InvalidOperationException("Could not find output writer"); + protected static TextWriter Output => TestContext.Current?.OutputWriter ?? throw new InvalidOperationException("Could not find output writer"); [NotNull] protected IApp? App { get; set; } diff --git a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs index a811694067..15da509acc 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs @@ -1,14 +1,9 @@ using System.Windows.Media; - namespace MaterialDesignThemes.UITests.WPF.Cards; public class OutlinedCardTests : TestBase { - public OutlinedCardTests(ITestOutputHelper output) - : base(output) - { } - [Test] public async Task OutlinedCard_UsesThemeColorForBorder() { @@ -24,7 +19,7 @@ public async Task OutlinedCard_UsesThemeColorForBorder() Color? internalBorderColor = await internalBorder.GetBorderBrushColor(); //Assert - await Assert.Equal(dividerColor, internalBorderColor); + await Assert.That(internalBorderColor).IsEqualTo(dividerColor); recorder.Success(); } @@ -43,10 +38,10 @@ public async Task OutlinedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnB CornerRadius? internalBorderCornerRadius = await internalBorder.GetCornerRadius(); //Assert - await Assert.Equal(5, internalBorderCornerRadius.Value.TopLeft); - await Assert.Equal(5, internalBorderCornerRadius.Value.TopRight); - await Assert.Equal(5, internalBorderCornerRadius.Value.BottomRight); - await 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 c81fc08918..4e190a9be4 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs @@ -1,16 +1,10 @@ using System.Windows.Media; using MaterialDesignColors.ColorManipulation; - namespace MaterialDesignThemes.UITests.WPF; public class ColorPickerTests : TestBase { - public ColorPickerTests(ITestOutputHelper output) - : base(output) - { - } - [Test] public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday() { @@ -35,7 +29,7 @@ public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday() double currentBrightness = (await colorPicker.GetColor()).ToHsb().Brightness; - await 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/DialogHosts/DialogHostTests.cs b/tests/MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs index d4f0dd3bdb..d24a7cf5b1 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs @@ -46,7 +46,10 @@ public async Task OnOpenDialog_OverlayCoversContent() await Wait.For(async () => await overlay.GetVisibility() != Visibility.Visible, retry); } await testOverlayButton.LeftClick(); - await Wait.For(async () => await Assert.That(await resultTextBlock.GetText()).IsEqualTo("Clicks: 2"), retry); + await Wait.For(async () => + { + await Assert.That((await resultTextBlock.GetText())!).IsEqualTo("Clicks: 2"); + }, retry); recorder.Success(); } @@ -67,7 +70,10 @@ public async Task ClosingDialogWithIsOpenProperty_ShouldRaiseDialogClosingEvent( await Task.Delay(300); await closeButton.LeftClick(); - await Wait.For(async () => await Assert.That(await resultTextBlock.GetText()).IsEqualTo("1")); + await Wait.For(async () => + { + await Assert.That(await resultTextBlock.GetText()).IsEqualTo("1"); + }); recorder.Success(); } @@ -226,7 +232,7 @@ await Wait.For(async () => { Color? foreground1 = await textBlock1.GetForegroundColor(); await Assert.That(foreground1).IsNotNull(); - AssertContrastRatio( + await AssertContrastRatio( foreground1.Value, await textBlock1.GetEffectiveBackground(), MinimumContrastSmallText); @@ -236,7 +242,7 @@ await Wait.For(async () => { Color? foreground2 = await textBlock2.GetForegroundColor(); await Assert.That(foreground2).IsNotNull(); - AssertContrastRatio( + await AssertContrastRatio( foreground2.Value, await textBlock2.GetEffectiveBackground(), MinimumContrastSmallText); diff --git a/tests/MaterialDesignThemes.UITests/WPF/ListBoxes/ListBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ListBoxes/ListBoxTests.cs index b25cfab2ef..903b8f3411 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/ListBoxes/ListBoxTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/ListBoxes/ListBoxTests.cs @@ -101,21 +101,21 @@ public async Task ScrollBarAssist_ButtonsVisibility_HidesButtonsOnMinimalistStyl var verticalScrollBar = await listBox.GetElement("PART_VerticalScrollBar"); var horizontalScrollBar = await listBox.GetElement("PART_HorizontalScrollBar"); - await Assert.Equal(17.0, await verticalScrollBar.GetActualWidth(), 1.0); + await Assert.That(await verticalScrollBar.GetActualWidth()).IsCloseTo(17.0, 1.0); var verticalThumb = await verticalScrollBar.GetElement("/Thumb~border"); - await Assert.Equal(10.0, await verticalThumb.GetActualWidth(), 1.0); + await Assert.That(await verticalThumb.GetActualWidth()).IsCloseTo(10.0, 1.0); var upButton = await verticalScrollBar.GetElement("PART_LineUpButton"); - await Assert.False(await upButton.GetIsVisible()); + await Assert.That(await upButton.GetIsVisible()).IsFalse(); var downButton = await verticalScrollBar.GetElement("PART_LineDownButton"); - await Assert.False(await downButton.GetIsVisible()); + await Assert.That(await downButton.GetIsVisible()).IsFalse(); - await Assert.Equal(17.0, await horizontalScrollBar.GetActualHeight(), 1.0); + await Assert.That(await horizontalScrollBar.GetActualHeight()).IsCloseTo(17.0, 1.0); var horizontalThumb = await horizontalScrollBar.GetElement("/Thumb~border"); - await Assert.Equal(10.0, await horizontalThumb.GetActualHeight(), 1.0); + await Assert.That(await horizontalThumb.GetActualHeight()).IsCloseTo(10.0, 1.0); var leftButton = await horizontalScrollBar.GetElement("PART_LineLeftButton"); - await Assert.False(await leftButton.GetIsVisible()); + await Assert.That(await leftButton.GetIsVisible()).IsFalse(); var rightButton = await horizontalScrollBar.GetElement("PART_LineRightButton"); - await Assert.False(await rightButton.GetIsVisible()); + await Assert.That(await rightButton.GetIsVisible()).IsFalse(); recorder.Success(); } @@ -135,7 +135,7 @@ public async Task OnListBoxAssist_WithShowSelectDisabled_SelectionIsDisabled() var earth = await listBox.GetElement("/ListBoxItem[2]"); await earth.LeftClick(); var selectedBorder = await earth.GetElement("SelectedBorder"); - await Wait.For(async () => await Assert.False(await selectedBorder.GetIsVisible())); + await Wait.For(async () => await Assert.That(await selectedBorder.GetIsVisible()).IsFalse()); recorder.Success(); } @@ -164,13 +164,13 @@ public async Task OnToggle_ShouldGrabFocus() var listBoxItem = await listBox.GetElement("/ListBoxItem[2]"); await textBox.LeftClick(); - await Wait.For(async () => await Assert.True(await textBox.GetIsKeyboardFocusWithin())); + await Wait.For(async () => await Assert.That(await textBox.GetIsKeyboardFocusWithin()).IsTrue()); // Act await listBoxItem.LeftClick(); // Assert - await Wait.For(async () => await Assert.True(await listBox.GetIsKeyboardFocusWithin())); + await Wait.For(async () => await Assert.That(await listBox.GetIsKeyboardFocusWithin()).IsTrue()); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/PasswordBoxes/PasswordBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/PasswordBoxes/PasswordBoxTests.cs index 492a659a20..248771afec 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/PasswordBoxes/PasswordBoxTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/PasswordBoxes/PasswordBoxTests.cs @@ -7,11 +7,6 @@ namespace MaterialDesignThemes.UITests.WPF.PasswordBoxes; public class PasswordBoxTests : TestBase { - public PasswordBoxTests(ITestOutputHelper output) - : base(output) - { - } - [Test] public async Task OnClearButtonShown_LayoutDoesNotChange() { @@ -31,7 +26,7 @@ public async Task OnClearButtonShown_LayoutDoesNotChange() //Assert var rect = await passwordBox.GetCoordinates(); - await Assert.Equal(initialRect, rect); + await Assert.That(rect).IsEqualTo(initialRect); recorder.Success(); } @@ -51,7 +46,7 @@ public async Task OnPasswordBoxHelperTextFontSize_ChangesHelperTextFontSize() double fontSize = await helpTextBlock.GetFontSize(); - await Assert.Equal(20, fontSize); + await Assert.That(fontSize).IsEqualTo(20); recorder.Success(); } @@ -72,14 +67,14 @@ public async Task OnPasswordBox_WithClearButton_ClearsPassword() string? password = await passwordBox.GetPassword(); - await Assert.NotNull(password); + await Assert.That(password).IsNotNull(); await clearButton.LeftClick(); await Wait.For(async () => { password = await passwordBox.GetPassword(); - await Assert.Null(password); + await Assert.That(password).IsNull(); }); recorder.Success(); @@ -121,17 +116,17 @@ public async Task RevealPasswordBox_WithBoundPasswordProperty_RespectsThreeWayBi string? clearTextPassword3 = await clearTextPasswordTextBox.GetProperty(TextBox.TextProperty); // Assert - await Assert.Equal("1", boundText1); - await Assert.Equal("1", password1); - await Assert.Equal("1", clearTextPassword1); + await Assert.That(boundText1).IsEqualTo("1"); + await Assert.That(password1).IsEqualTo("1"); + await Assert.That(clearTextPassword1).IsEqualTo("1"); - await Assert.Equal("12", boundText2); - await Assert.Equal("12", password2); - await Assert.Equal("12", clearTextPassword2); + await Assert.That(boundText2).IsEqualTo("12"); + await Assert.That(password2).IsEqualTo("12"); + await Assert.That(clearTextPassword2).IsEqualTo("12"); - await Assert.Equal("3", boundText3); - await Assert.Equal("3", password3); - await Assert.Equal("3", clearTextPassword3); + await Assert.That(boundText3).IsEqualTo("3"); + await Assert.That(password3).IsEqualTo("3"); + await Assert.That(clearTextPassword3).IsEqualTo("3"); recorder.Success(); } @@ -159,11 +154,11 @@ public async Task PasswordBox_WithBoundPasswordProperty_RespectsBinding() string? password2 = await passwordBox.GetProperty(nameof(PasswordBox.Password)); // Assert - await Assert.Equal("1", boundText1); - await Assert.Equal("1", password1); + await Assert.That(boundText1).IsEqualTo("1"); + await Assert.That(password1).IsEqualTo("1"); - await Assert.Equal("2", boundText2); - await Assert.Equal("2", password2); + await Assert.That(boundText2).IsEqualTo("2"); + await Assert.That(password2).IsEqualTo("2"); recorder.Success(); } @@ -185,7 +180,7 @@ public async Task PasswordBox_WithRevealStyle_RespectsMaxLength() int maxLength2 = await revealPasswordTextBox.GetMaxLength(); // Assert - await Assert.Equal(maxLength1, maxLength2); + await Assert.That(maxLength2).IsEqualTo(maxLength1); recorder.Success(); } @@ -234,8 +229,10 @@ public async Task PasswordBox_WithHintAndHelperText_RespectsPadding(string style Rect? hintCoordinates = await hint.GetCoordinates(); Rect? helperTextCoordinates = await helperText.GetCoordinates(); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left), 0, tolerance); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left), 0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)) + .IsBetween(0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)) + .IsBetween(0, tolerance); recorder.Success(); } @@ -292,13 +289,16 @@ public async Task PasswordBox_WithHintAndValidationError_RespectsPadding(string Rect? hintCoordinates = await hint.GetCoordinates(); Rect? errorViewerCoordinates = await errorViewer.GetCoordinates(); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left), 0, tolerance); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left), 0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)) + .IsBetween(0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)) + .IsBetween(0, tolerance); recorder.Success(); } - [Fact(Skip = "Ignoring until I can figure out why this doesn't work on the GitHub Actions runner")] + [Test] + [Skip("Ignoring until I can figure out why this doesn't work on the GitHub Actions runner")] [Description("Issue 3095")] public async Task PasswordBox_WithRevealedPassword_RespectsKeyboardTabNavigation() { @@ -320,17 +320,17 @@ public async Task PasswordBox_WithRevealedPassword_RespectsKeyboardTabNavigation // Assert Tab forward await textBox1.MoveKeyboardFocus(); - await Assert.True(await textBox1.GetIsKeyboardFocused()); + await Assert.That(await textBox1.GetIsKeyboardFocused()).IsTrue(); await textBox1.SendKeyboardInput($"{Key.Tab}"); - await Assert.True(await revealPasswordTextBox.GetIsKeyboardFocused()); + await Assert.That(await revealPasswordTextBox.GetIsKeyboardFocused()).IsTrue(); await revealPasswordTextBox.SendKeyboardInput($"{Key.Tab}"); - await Assert.True(await textBox2.GetIsKeyboardFocused()); + await Assert.That(await textBox2.GetIsKeyboardFocused()).IsTrue(); // Assert Tab backwards await textBox2.SendKeyboardInput($"{ModifierKeys.Shift}{Key.Tab}"); - await Assert.True(await revealPasswordTextBox.GetIsKeyboardFocused()); + await Assert.That(await revealPasswordTextBox.GetIsKeyboardFocused()).IsTrue(); await revealPasswordTextBox.SendKeyboardInput($"{Key.Tab}{ModifierKeys.None}"); - await Assert.True(await textBox1.GetIsKeyboardFocused()); + await Assert.That(await textBox1.GetIsKeyboardFocused()).IsTrue(); recorder.Success(); } @@ -355,13 +355,13 @@ public async Task PasswordBox_WithRevealButtonIsTabStopSetToFalse_RespectsKeyboa // Assert Tab forward await passwordBox.MoveKeyboardFocus(); - await Assert.True(await passwordBox.GetIsKeyboardFocused()); + await Assert.That(await passwordBox.GetIsKeyboardFocused()).IsTrue(); await passwordBox.SendKeyboardInput($"{Key.Tab}"); - await Assert.True(await textBox.GetIsKeyboardFocused()); + await Assert.That(await textBox.GetIsKeyboardFocused()).IsTrue(); // Assert Tab backwards await textBox.SendKeyboardInput($"{ModifierKeys.Shift}{Key.Tab}{ModifierKeys.None}"); - await Assert.True(await passwordBox.GetIsKeyboardFocused()); + await Assert.That(await passwordBox.GetIsKeyboardFocused()).IsTrue(); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/PopupBoxes/PopupBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/PopupBoxes/PopupBoxTests.cs index 4dc3b52f32..9eafa9c7ec 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/PopupBoxes/PopupBoxTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/PopupBoxes/PopupBoxTests.cs @@ -2,15 +2,10 @@ using System.Windows.Media; using MaterialDesignThemes.UITests.Samples.PopupBox; - namespace MaterialDesignThemes.UITests.WPF.PopupBoxes; public class PopupBoxTests : TestBase { - public PopupBoxTests(ITestOutputHelper output) - : base(output) - { } - [Test] [Arguments(Elevation.Dp0)] [Arguments(Elevation.Dp16)] @@ -33,7 +28,7 @@ public async Task PopupBox_WithElevation_AppliesElevationToNestedCard(Elevation IVisualElement card = await popupBox.GetElement("/Card"); // Assert - await Assert.Equal(elevation, await card.GetProperty(ElevationAssist.ElevationProperty)); + await Assert.That(await card.GetProperty(ElevationAssist.ElevationProperty)).IsEqualTo(elevation); recorder.Success(); } @@ -52,14 +47,14 @@ public async Task PopupBox_WithContentTemplateSelector_ChangesContent() // Assert var border = await popupBox.GetElement(); - await Assert.Equal(Colors.Blue, await border.GetBackgroundColor()); + await Assert.That(await border.GetBackgroundColor()).IsEqualTo(Colors.Blue); await button.LeftClick(); await Wait.For(async () => { border = await popupBox.GetElement(); - await Assert.Equal(Colors.Red, await border.GetBackgroundColor()); + await Assert.That(await border.GetBackgroundColor()).IsEqualTo(Colors.Red); }); diff --git a/tests/MaterialDesignThemes.UITests/WPF/SnackBars/SnackBarTests.cs b/tests/MaterialDesignThemes.UITests/WPF/SnackBars/SnackBarTests.cs index a299c965b0..dd5e096ad5 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/SnackBars/SnackBarTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/SnackBars/SnackBarTests.cs @@ -1,15 +1,9 @@ using System.ComponentModel; - namespace MaterialDesignThemes.UITests.WPF.SnackBars; public class SnackBarTests : TestBase { - public SnackBarTests(ITestOutputHelper output) - : base(output) - { - } - [Test] [Description("Issue 1223")] public async Task SnackBar_WithFontSizeAndWeight_AffectsDisplayedMessage() @@ -28,8 +22,8 @@ public async Task SnackBar_WithFontSizeAndWeight_AffectsDisplayedMessage() IVisualElement textBlock = await snackBar.GetElement(); // Assert - await Assert.Equal(14, await textBlock.GetFontSize()); - await Assert.Equal(FontWeights.Bold, await textBlock.GetFontWeight()); + await Assert.That(await textBlock.GetFontSize()).IsEqualTo(14); + await Assert.That(await textBlock.GetFontWeight()).IsEqualTo(FontWeights.Bold); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/SplitButtons/SplitButtonTests.cs b/tests/MaterialDesignThemes.UITests/WPF/SplitButtons/SplitButtonTests.cs index b83bf2d98f..5c044eec0c 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/SplitButtons/SplitButtonTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/SplitButtons/SplitButtonTests.cs @@ -5,14 +5,8 @@ namespace MaterialDesignThemes.UITests.WPF.SplitButtons; - public class SplitButtonTests : TestBase { - public SplitButtonTests(ITestOutputHelper output) - : base(output) - { - } - [Test] public async Task SplitButton_ClickingSplitButton_ShowsPopup() { @@ -68,9 +62,9 @@ public async Task SplitButton_RegisterForClick_RaisesEvent() int rightButtonCount = (await clickEvent.GetInvocations()).Count; // Assert - await Assert.Equal(1, leftButtonCount); + await Assert.That(leftButtonCount).IsEqualTo(1); //NB: The popup box button should only show the popup not trigger the click event - await Assert.Equal(1, rightButtonCount); + await Assert.That(rightButtonCount).IsEqualTo(1); recorder.Success(); } @@ -104,7 +98,7 @@ public async Task SplitButton_WithButtonInPopup_CanBeInvoked() // Assert var invocations = await clickEvent.GetInvocations(); - await Assert.Single(invocations); + await Assert.That(invocations).HasSingleItem(); recorder.Success(); } @@ -120,14 +114,14 @@ public async Task SplitButton_RegisterCommandBinding_InvokesCommand() IVisualElement userControl = await window.GetElement(); IVisualElement splitButton = await userControl.GetElement(); - await Assert.False(await userControl.GetCommandInvoked()); + await Assert.That(await userControl.GetCommandInvoked()).IsFalse(); //Act await splitButton.LeftClick(); await Task.Delay(50); // Assert - await Assert.True(await userControl.GetCommandInvoked()); + await Assert.That(await userControl.GetCommandInvoked()).IsTrue(); recorder.Success(); } @@ -143,13 +137,13 @@ public async Task SplitButton_CommandCanExecuteFalse_DisablesButton() IVisualElement userControl = await window.GetElement(); IVisualElement splitButton = await userControl.GetElement(); - await Assert.True(await splitButton.GetIsEnabled()); + await Assert.That(await splitButton.GetIsEnabled()).IsTrue(); //Act await userControl.SetProperty(nameof(SplitButtonWithCommandBinding.CommandCanExecute), false); // Assert - await Assert.False(await splitButton.GetIsEnabled()); + await Assert.That(await splitButton.GetIsEnabled()).IsFalse(); recorder.Success(); } @@ -185,8 +179,8 @@ public async Task SplitButton_ClickingPopupContent_DoesNotExecuteSplitButtonClic await Task.Delay(50); // Assert - await Assert.Empty(await splitButtonClickEvent.GetInvocations()); - await Assert.Single(await popupContentClickEvent.GetInvocations()); + await Assert.That(await splitButtonClickEvent.GetInvocations()).IsEmpty(); + await Assert.That(await popupContentClickEvent.GetInvocations()).HasSingleItem(); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/TabControls/TabControlTests.cs b/tests/MaterialDesignThemes.UITests/WPF/TabControls/TabControlTests.cs index 2385ed5c67..96b7c1e9a8 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/TabControls/TabControlTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/TabControls/TabControlTests.cs @@ -6,10 +6,6 @@ namespace MaterialDesignThemes.UITests.WPF.TabControls; public class TabControlTests : TestBase { - public TabControlTests(ITestOutputHelper output) - : base(output) - { } - [Test] [Description("Issue 2602")] public async Task OnLoad_ThemeBrushesSet() @@ -38,12 +34,12 @@ public async Task OnLoad_ThemeBrushesSet() Color? selectedTabUnderline = await selectedTabBorder.GetBorderBrushColor(); //Assert - await Assert.NotNull(foreground); - await Assert.NotNull(background); + await Assert.That(foreground).IsNotNull(); + await Assert.That(background).IsNotNull(); - MaterialDesignSpec.AssertContrastRatio(foreground.Value, background.Value, MaterialDesignSpec.MinimumContrastSmallText); + await MaterialDesignSpec.AssertContrastRatio(foreground.Value, background.Value, MaterialDesignSpec.MinimumContrastSmallText); - await Assert.Equal(foreground, selectedTabUnderline); + await Assert.That(selectedTabUnderline).IsEqualTo(foreground); recorder.Success(); } @@ -106,7 +102,7 @@ public async Task TabItem_ShouldKeepDataContext_WhenContextMenuOpens(string hori // Assert initial data context IVisualElement tabItem = await tabControl.GetElement(); object? dataContext = await tabItem.GetDataContext(); - await Assert.Equal("aaaa", dataContext); + await Assert.That(dataContext).IsEqualTo("aaaa"); // Act await button.MoveCursorTo(); @@ -118,7 +114,7 @@ public async Task TabItem_ShouldKeepDataContext_WhenContextMenuOpens(string hori // Assert data context still present tabItem = await tabControl.GetElement(); dataContext = await tabItem.GetDataContext(); - await Assert.Equal("aaaa", dataContext); + await Assert.That(dataContext).IsEqualTo("aaaa"); recorder.Success(); } @@ -151,8 +147,8 @@ public async Task TabControl_ShouldRespectSelectedContentTemplate_WhenSetDirectl IVisualElement customContent = await customContentBorder.GetElement(@"/TextBlock"); //Assert - await Assert.Equal(Colors.Fuchsia, await customContentBorder.GetBackgroundColor()); - await Assert.Equal("Tab content string", await customContent.GetText()); + await Assert.That(await customContentBorder.GetBackgroundColor()).IsEqualTo(Colors.Fuchsia); + await Assert.That(await customContent.GetText()).IsEqualTo("Tab content string"); recorder.Success(); } diff --git a/tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs index 55ecc6dd68..85da82afc9 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs @@ -3,16 +3,10 @@ using System.Windows.Media; using MaterialDesignThemes.UITests.Samples.Validation; - namespace MaterialDesignThemes.UITests.WPF.TextBoxes; public class TextBoxTests : TestBase { - public TextBoxTests(ITestOutputHelper output) - : base(output) - { - } - [Test] [Description("Issue 1883")] public async Task OnClearButtonShown_ControlHeightDoesNotChange() @@ -43,7 +37,7 @@ public async Task OnClearButtonShown_ControlHeightDoesNotChange() await Task.Delay(MaterialDesignTextBox.FocusedAnimationTime); double height = await textBox.GetActualHeight(); - await Assert.Equal(initialHeight, height); + await Assert.That(height).IsEqualTo(initialHeight); recorder.Success(); } @@ -82,7 +76,7 @@ public async Task OnClearButtonWithHintShown_ControlHeightDoesNotChange() //Assert double height = await textBox.GetActualHeight(); - await Assert.Equal(initialHeight, height); + await Assert.That(height).IsEqualTo(initialHeight); recorder.Success(); } @@ -113,9 +107,9 @@ public async Task OnTextCleared_MultilineTextBox() await textBox.SetText(""); //Assert - await Wait.For(async () => await Assert.Equal(initialHeight, await textBox.GetActualHeight())); + await Wait.For(async () => await Assert.That(await textBox.GetActualHeight()).IsEqualTo(initialHeight)); Rect rect = await textBox.GetCoordinates(); - await Assert.Equal(initialRect, rect); + await Assert.That(rect).IsEqualTo(initialRect); recorder.Success(); } @@ -137,14 +131,14 @@ public async Task OnTextBox_WithClearButton_ClearsText() string? text = await textBox.GetText(); - await Assert.NotNull(text); + await Assert.That(text).IsNotNull(); await clearButton.LeftClick(); await Wait.For(async () => { text = await textBox.GetText(); - await Assert.Null(text); + await Assert.That(text).IsNull(); }); recorder.Success(); @@ -174,7 +168,7 @@ public async Task OnTextBoxDisabled_FloatingHintBackgroundIsOpaque() Color background = await hintBackground.GetEffectiveBackground(contentGrid); - await Assert.Equal(255, background.A); + await Assert.That(background.A).IsEqualTo(255); recorder.Success(); } @@ -196,7 +190,7 @@ public async Task OnTextBoxHelperTextFontSize_ChangesHelperTextFontSize() double fontSize = await helpTextBlock.GetFontSize(); - await Assert.Equal(20, fontSize); + await Assert.That(fontSize).IsEqualTo(20); recorder.Success(); } @@ -214,11 +208,11 @@ public async Task CharacterCount_WithMaxLengthSet_IsDisplayed() var textBox = await grid.GetElement("/TextBox"); var characterCounter = await textBox.GetElement("CharacterCounterTextBlock"); - await Assert.Equal("0 / 10", await characterCounter.GetText()); + await Assert.That(await characterCounter.GetText()).IsEqualTo("0 / 10"); await textBox.SetText("12345"); - await Assert.Equal("5 / 10", await characterCounter.GetText()); + await Assert.That(await characterCounter.GetText()).IsEqualTo("5 / 10"); recorder.Success(); } @@ -235,7 +229,7 @@ public async Task CharacterCount_WithoutMaxLengthSet_IsCollapsed() var textBox = await grid.GetElement("/TextBox"); var characterCounter = await textBox.GetElement("CharacterCounterTextBlock"); - await Assert.False(await characterCounter.GetIsVisible()); + await Assert.That(await characterCounter.GetIsVisible()).IsFalse(); recorder.Success(); } @@ -255,7 +249,7 @@ public async Task CharacterCount_WithMaxLengthSetAndCharacterCounterVisibilityCo var textBox = await grid.GetElement("/TextBox"); var characterCounter = await textBox.GetElement("CharacterCounterTextBlock"); - await Assert.False(await characterCounter.GetIsVisible()); + await Assert.That(await characterCounter.GetIsVisible()).IsFalse(); recorder.Success(); } @@ -280,7 +274,7 @@ public async Task HelperText_CanSetFontColorWithAttachedStyle() var textBox = await grid.GetElement("/TextBox"); var helperText = await textBox.GetElement("HelperTextTextBlock"); - await Assert.Equal(Colors.Red, await helperText.GetForegroundColor()); + await Assert.That(await helperText.GetForegroundColor()).IsEqualTo(Colors.Red); recorder.Success(); } @@ -301,8 +295,8 @@ public async Task FloatingOffset_ValuesGetAppropriatelyApplied() var hint = await textBox.GetElement("Hint"); Point offset = await hint.GetFloatingOffset(); - await Assert.Equal(1, offset.X); - await Assert.Equal(-42, offset.Y); + await Assert.That(offset.X).IsEqualTo(1); + await Assert.That(offset.Y).IsEqualTo(-42); recorder.Success(); } @@ -320,10 +314,10 @@ public async Task ContextMenu_FollowsTextBoxFontFamily() var contextMenu = await textBox.GetElement(".ContextMenu"); FontFamily? textBoxFont = await textBox.GetFontFamily(); - await Assert.Contains("Times New Roman", textBoxFont?.FamilyNames.Values ?? []); + await Assert.That(textBoxFont?.FamilyNames.Values ?? []).Contains("Times New Roman"); await Wait.For(async () => { - await Assert.Equal(textBoxFont, await contextMenu.GetFontFamily()); + await Assert.That(await contextMenu.GetFontFamily()).IsEqualTo(textBoxFont); }); recorder.Success(); @@ -346,8 +340,8 @@ public async Task ContextMenu_UsesInheritedFontFamily() var contextMenu = await textBox.GetElement(".ContextMenu"); var textBoxFont = await textBox.GetFontFamily(); - await Assert.Equal("Times New Roman", textBoxFont?.FamilyNames.Values.First()); - await Assert.Equal(textBoxFont, await contextMenu.GetFontFamily()); + await Assert.That(textBoxFont?.FamilyNames.Values.First()).IsEqualTo("Times New Roman"); + await Assert.That(await contextMenu.GetFontFamily()).IsEqualTo(textBoxFont); recorder.Success(); } @@ -366,12 +360,12 @@ public async Task VerticalContentAlignment_ProperlyAlignsText() //The default for this changed with issue 2556. //It should be stretch so that the horizontal scroll bar is at the bottom and not //pushed to the bottom of the text. - await Assert.Equal(VerticalAlignment.Stretch, await scrollViewer.GetVerticalAlignment()); + await Assert.That(await scrollViewer.GetVerticalAlignment()).IsEqualTo(VerticalAlignment.Stretch); foreach (var alignment in Enum.GetValues()) { await textBox.SetVerticalContentAlignment(alignment); - await Assert.Equal(alignment, await scrollViewer.GetVerticalContentAlignment()); + await Assert.That(await scrollViewer.GetVerticalContentAlignment()).IsEqualTo(alignment); } recorder.Success(); @@ -407,10 +401,9 @@ public async Task OutlinedTextBox_ValidationErrorMargin_MatchesHelperTextMargin( Thickness? errorMargin = await errorViewer.GetMargin(); Thickness? textBoxPadding = await textBox.GetPadding(); - await Assert.True(errorMargin.HasValue); - await Assert.True(textBoxPadding.HasValue); - await Assert.True(Math.Abs(errorMargin.Value.Left - textBoxPadding.Value.Left) < double.Epsilon, - $"Error text does not respect the padding of the TextBox: Error text Margin.Left ({errorMargin.Value.Left}) == TextBox Padding.Left ({textBoxPadding.Value.Left})"); + await Assert.That(errorMargin.HasValue).IsTrue(); + await Assert.That(textBoxPadding.HasValue).IsTrue(); + await Assert.That(errorMargin.Value.Left - textBoxPadding.Value.Left).IsZero().Because($"Error text does not respect the padding of the TextBox: Error text Margin.Left ({errorMargin.Value.Left}) == TextBox Padding.Left ({textBoxPadding.Value.Left})"); recorder.Success(); } @@ -445,11 +438,10 @@ public async Task FilledTextBox_ValidationErrorMargin_MatchesHelperTextMargin() Thickness? errorMargin = await errorViewer.GetProperty(FrameworkElement.MarginProperty); Thickness? textBoxPadding = await textBox.GetProperty(Control.PaddingProperty); - await Assert.True(errorMargin.HasValue); - await Assert.True(textBoxPadding.HasValue); + await Assert.That(errorMargin.HasValue).IsTrue(); + await Assert.That(textBoxPadding.HasValue).IsTrue(); - await Assert.True(Math.Abs(errorMargin.Value.Left - textBoxPadding.Value.Left) < double.Epsilon, - $"Error text does not respect the padding of the TextBox: Error text Margin.Left ({errorMargin.Value.Left}) == TextBox Padding.Left ({textBoxPadding.Value.Left})"); + await Assert.That(errorMargin.Value.Left - textBoxPadding.Value.Left).IsZero().Because($"Error text does not respect the padding of the TextBox: Error text Margin.Left ({errorMargin.Value.Left}) == TextBox Padding.Left ({textBoxPadding.Value.Left})"); recorder.Success(); } @@ -489,8 +481,8 @@ public async Task TextBox_WithHintAndHelperText_RespectsPadding(string styleName Rect? hintCoordinates = await hint.GetCoordinates(); Rect? helperTextCoordinates = await helperText.GetCoordinates(); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left), 0, tolerance); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left), 0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsBetween(0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsBetween(0, tolerance); recorder.Success(); } @@ -538,8 +530,8 @@ public async Task TextBox_WithHintAndValidationError_RespectsPadding(string styl Rect? hintCoordinates = await hint.GetCoordinates(); Rect? errorViewerCoordinates = await errorViewer.GetCoordinates(); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left), 0, tolerance); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left), 0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsBetween(0, tolerance); + await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsBetween(0, tolerance); recorder.Success(); } @@ -567,7 +559,7 @@ public async Task TextBox_MultiLineAndFixedHeight_RespectsVerticalContentAlignme IVisualElement textBox = await stackPanel.GetElement("/TextBox"); IVisualElement contentGrid = await textBox.GetElement("ContentGrid"); - await Assert.Equal(expectedFloatingHintAlignment, await contentGrid.GetVerticalAlignment()); + await Assert.That(await contentGrid.GetVerticalAlignment()).IsEqualTo(expectedFloatingHintAlignment); recorder.Success(); } @@ -588,7 +580,7 @@ await Wait.For(async() => var errorViewer = await textBox.GetElement("DefaultErrorViewer"); var textBlock = await errorViewer.GetElement(); - await Assert.Equal("Some error + more", await textBlock.GetText()); + await Assert.That(await textBlock.GetText()).IsEqualTo("Some error + more"); }); recorder.Success(); diff --git a/tests/MaterialDesignThemes.UITests/WPF/TextFieldDefaultHeightTests.cs b/tests/MaterialDesignThemes.UITests/WPF/TextFieldDefaultHeightTests.cs index 29a938c477..d1ba4a41cd 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/TextFieldDefaultHeightTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/TextFieldDefaultHeightTests.cs @@ -1,10 +1,8 @@ - - namespace MaterialDesignThemes.UITests.WPF; -public class TextFieldDefaultHeightTests(ITestOutputHelper output) : TestBase(output) +public class TextFieldDefaultHeightTests : TestBase { - private const int Precision = 3; + private const double Precision = 0.001; [Test] public async Task SameHeightWithDefaultStyle() @@ -22,10 +20,11 @@ public async Task SameHeightWithDefaultStyle() """); double height = await GetHeight(stackPanel, "TextBox"); - await Assert.Equal(height, await GetHeight(stackPanel, "PasswordBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "DatePicker"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision); + + await Assert.That(await GetHeight(stackPanel, "PasswordBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "ComboBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "DatePicker")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "TimePicker")).IsCloseTo(height, Precision); recorder.Success(); } @@ -47,11 +46,11 @@ public async Task SameHeightWithFloatingHintStyle() """); double height = await GetHeight(stackPanel, "TextBox"); - await Assert.Equal(height, await GetHeight(stackPanel, "PasswordBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "PasswordBox", "RevealPasswordBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "DatePicker"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision); + await Assert.That(await GetHeight(stackPanel, "PasswordBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "PasswordBox", "RevealPasswordBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "ComboBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "DatePicker")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "TimePicker")).IsCloseTo(height, Precision); recorder.Success(); } @@ -73,11 +72,11 @@ public async Task SameHeightWithFilledStyle() """); double height = await GetHeight(stackPanel, "TextBox"); - await Assert.Equal(height, await GetHeight(stackPanel, "PasswordBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "PasswordBox", "RevealPasswordBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "DatePicker"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision); + await Assert.That(await GetHeight(stackPanel, "PasswordBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "PasswordBox", "RevealPasswordBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "ComboBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "DatePicker")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "TimePicker")).IsCloseTo(height, Precision); recorder.Success(); } @@ -99,11 +98,11 @@ public async Task SameHeightWithOutlinedStyle() """); double height = await GetHeight(stackPanel, "TextBox"); - await Assert.Equal(height, await GetHeight(stackPanel, "PasswordBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "PasswordBox", "RevealPasswordBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "DatePicker"), Precision); - await Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision); + await Assert.That(await GetHeight(stackPanel, "PasswordBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "PasswordBox", "RevealPasswordBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "ComboBox")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "DatePicker")).IsCloseTo(height, Precision); + await Assert.That(await GetHeight(stackPanel, "TimePicker")).IsCloseTo(height, Precision); recorder.Success(); } @@ -112,7 +111,7 @@ private static async Task GetHeight(IVisualElement container, string typ { var element = await container.GetElement(optionalName ?? "/" + type); double height = await element.GetActualHeight(); - await Assert.True(height > 0); + await Assert.That(height > 0).IsTrue(); return height; } } diff --git a/tests/MaterialDesignThemes.UITests/WPF/Theme/ColorAdjustTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Theme/ColorAdjustTests.cs index b8522cb9e5..a7499a76c8 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Theme/ColorAdjustTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Theme/ColorAdjustTests.cs @@ -3,20 +3,15 @@ using MaterialDesignColors.ColorManipulation; using MaterialDesignThemes.UITests.Samples.Theme; - namespace MaterialDesignThemes.UITests.WPF.Theme; public class ColorAdjustTests : TestBase { - public ColorAdjustTests(ITestOutputHelper output) - : base(output) - { } - - public static IEnumerable PrimaryColors() + public static IEnumerable> PrimaryColors() { return Enum.GetValues(typeof(PrimaryColor)) .OfType() - .Select(x => new object[] { x }); + .Select(x => new Func(() => x)); } [Test] @@ -53,10 +48,11 @@ async Task AssertContrastRatio() Color? smallTextForeground = await smallText.GetForegroundColor(); Color smallTextBackground = await smallText.GetEffectiveBackground(); - var largeContrastRatio = ColorAssist.ContrastRatio(largeTextForeground.Value, largeTextBackground); - await Assert.True(largeContrastRatio >= MaterialDesignSpec.MinimumContrastLargeText - tolerance, $"Large font contrast ratio '{largeContrastRatio}' does not meet material design spec {MaterialDesignSpec.MinimumContrastLargeText}"); - var smallContrastRatio = ColorAssist.ContrastRatio(smallTextForeground.Value, smallTextBackground); - await Assert.True(smallContrastRatio >= MaterialDesignSpec.MinimumContrastSmallText - tolerance, $"Small font contrast ratio '{smallContrastRatio}' does not meet material design spec {MaterialDesignSpec.MinimumContrastSmallText}"); + double largeContrastRatio = ColorAssist.ContrastRatio(largeTextForeground.Value, largeTextBackground); + await Assert.That(largeContrastRatio).IsGreaterThanOrEqualTo(MaterialDesignSpec.MinimumContrastLargeText - tolerance) + .Because($"Large font contrast ratio '{largeContrastRatio}' does not meet material design spec {MaterialDesignSpec.MinimumContrastLargeText}"); + double smallContrastRatio = ColorAssist.ContrastRatio(smallTextForeground.Value, smallTextBackground); + await Assert.That(smallContrastRatio).IsGreaterThanOrEqualTo(MaterialDesignSpec.MinimumContrastSmallText - tolerance).Because($"Small font contrast ratio '{smallContrastRatio}' does not meet material design spec {MaterialDesignSpec.MinimumContrastSmallText}"); } } } diff --git a/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.cs index fc611450e7..2012c1e3ca 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.cs @@ -1,5 +1,4 @@ -using System.Reflection; -using System.Windows.Media; +using System.Windows.Media; using MaterialDesignColors; @@ -7,10 +6,6 @@ namespace MaterialDesignThemes.UITests.WPF.Theme; public partial class ThemeTests : TestBase { - public ThemeTests(ITestOutputHelper output) - : base(output) - { } - [Test] public async Task WhenUsingBuiltInLightXamlThemeDictionary_AllBrushesApplied() { @@ -60,22 +55,16 @@ public async Task WhenUsingCustomColorThemeDictionary_AllBrushesApplied() await AssertAllThemeBrushesSet(panel); } - public static IEnumerable ThemeCombinations() - { - var baseThemes = new[] { "Light", "Dark" }; - var primaryColors = Enum.GetNames(); - var secondaryColors = Enum.GetNames(); - - return (from baseTheme in baseThemes - from primaryColor in primaryColors - from secondaryColor in secondaryColors - select new object[] { baseTheme, primaryColor, secondaryColor }); + private static PrimaryColor[] PrimaryColors() => Enum.GetValues(); + private static SecondaryColor[] SecondaryColors() => Enum.GetValues(); - } - - [Theory(Skip = "Manual run when theme values change")] - [MemberData(nameof(ThemeCombinations))] - public async Task BundledTheme_UsesSameColorsAsXamlResources(string baseTheme, string primaryColor, string secondaryColor) + [Test] + [Skip("Manual run when theme values change")] + [MatrixDataSource] + public async Task BundledTheme_UsesSameColorsAsXamlResources( + [Matrix("Light", "Dark")] string baseTheme, + [MatrixMethod(nameof(PrimaryColors))] PrimaryColor primaryColor, + [MatrixMethod(nameof(SecondaryColors))] SecondaryColor secondaryColor) { IVisualElement bundledPanel = await Initialize($""" xamlColorsByNames = await GetColors(); - await Assert.Equal(bundledColorsByNames.Count, xamlColorsByNames.Count); + await Assert.That(xamlColorsByNames.Count).IsEqualTo(bundledColorsByNames.Count); foreach (string brushName in GetBrushResourceNames()) { - bool areEqual = bundledColorsByNames[brushName] == xamlColorsByNames[brushName]; - await Assert.True(areEqual, $"Brush {brushName}, Bundled color {bundledColorsByNames[brushName]} does not match XAML color {xamlColorsByNames[brushName]}"); + await Assert.That(bundledColorsByNames[brushName] == xamlColorsByNames[brushName]).IsTrue().Because($"Brush {brushName}, Bundled color {bundledColorsByNames[brushName]} does not match XAML color {xamlColorsByNames[brushName]}"); } async Task> GetColors() @@ -128,8 +116,8 @@ private async Task GetResourceColor(string name) { IResource resource = await App.GetResource(name); SolidColorBrush? brush = resource.GetAs(); - await Assert.NotNull(brush); - return brush.Color; + await Assert.That(brush).IsNotNull(); + return brush!.Color; } protected async Task> Initialize(string themeDictionary) @@ -153,7 +141,7 @@ protected async Task> Initialize(string themeDictionar await App.Initialize(applicationResourceXaml, Path.GetFullPath("MaterialDesignColors.dll"), Path.GetFullPath("MaterialDesignThemes.Wpf.dll"), - Assembly.GetExecutingAssembly().Location); + System.Reflection.Assembly.GetExecutingAssembly().Location); return await App.CreateWindowWith(GetXamlWrapPanel()); } } diff --git a/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.g.cs b/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.g.cs index 4e346dda43..bd84f89b83 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.g.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/Theme/ThemeTests.g.cs @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------ // -// This code was generated by mdresgen. +// This code was generated by MaterialDesignToolkit.ResourceGeneration. // //------------------------------------------------------------------------------ @@ -186,727 +186,727 @@ private partial async Task AssertAllThemeBrushesSet(IVisualElement pa { IVisualElement textBlock = await panel.GetElement("[Text=\"Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Foreground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Foreground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Foreground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ForegroundLight\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ForegroundLight"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ForegroundLight")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ValidationError\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ValidationError"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ValidationError")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Badged.DarkBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Badged.DarkBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Badged.DarkBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Badged.DarkForeground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Badged.DarkForeground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Badged.DarkForeground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Badged.LightBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Badged.LightBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Badged.LightBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Badged.LightForeground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Badged.LightForeground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Badged.LightForeground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Button.FlatClick\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Button.FlatClick"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Button.FlatClick")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Button.Ripple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Button.Ripple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Button.Ripple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Button.FlatRipple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Button.FlatRipple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Button.FlatRipple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"SnackBar.Ripple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.SnackBar.Ripple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.SnackBar.Ripple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"SnackBar.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.SnackBar.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.SnackBar.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"SnackBar.MouseOver\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.SnackBar.MouseOver"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.SnackBar.MouseOver")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Card.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Card.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Card.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Card.Border\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Card.Border"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Card.Border")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"CheckBox.Disabled\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.CheckBox.Disabled"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.CheckBox.Disabled")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"CheckBox.UncheckedBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.CheckBox.UncheckedBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.CheckBox.UncheckedBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"CheckBox.Off\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.CheckBox.Off"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.CheckBox.Off")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Chip.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Chip.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Chip.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Chip.OutlineBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Chip.OutlineBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Chip.OutlineBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ColorZone.DarkBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ColorZone.DarkBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ColorZone.DarkBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ColorZone.DarkForeground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ColorZone.DarkForeground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ColorZone.DarkForeground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ColorZone.LightBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ColorZone.LightBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ColorZone.LightBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ColorZone.LightForeground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ColorZone.LightForeground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ColorZone.LightForeground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.Disabled\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.Disabled"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.Disabled")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.FilledBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.FilledBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.FilledBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.HoverBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.HoverBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.HoverBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.OutlineInactiveBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.OutlineInactiveBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.OutlineInactiveBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.HoverBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.HoverBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.HoverBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.Border\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.Border"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.Border")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.OutlineBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.OutlineBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.OutlineBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.Popup.DarkBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.Popup.DarkBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.Popup.DarkBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.Popup.DarkForeground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.Popup.DarkForeground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.Popup.DarkForeground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.Popup.LightBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.Popup.LightBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.Popup.LightBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ComboBox.Popup.LightForeground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ComboBox.Popup.LightForeground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ComboBox.Popup.LightForeground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"DataGrid.Border\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.DataGrid.Border"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.DataGrid.Border")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"DataGrid.ButtonPressed\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.DataGrid.ButtonPressed"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.DataGrid.ButtonPressed")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"DataGrid.ComboBoxHover\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.DataGrid.ComboBoxHover"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.DataGrid.ComboBoxHover")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"DataGrid.ComboBoxSelected\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.DataGrid.ComboBoxSelected"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.DataGrid.ComboBoxSelected")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"DataGrid.PopupBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.DataGrid.PopupBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.DataGrid.PopupBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"DataGrid.RowHoverBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.DataGrid.RowHoverBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.DataGrid.RowHoverBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"DataGrid.Selected\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.DataGrid.Selected"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.DataGrid.Selected")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"DataGrid.ColumnHeaderForeground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.DataGrid.ColumnHeaderForeground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.DataGrid.ColumnHeaderForeground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"TextBox.HoverBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.TextBox.HoverBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.TextBox.HoverBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"TextBox.Border\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.TextBox.Border"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.TextBox.Border")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"TextBox.OutlineBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.TextBox.OutlineBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.TextBox.OutlineBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"TextBox.DisabledBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.TextBox.DisabledBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.TextBox.DisabledBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"TextBox.FilledBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.TextBox.FilledBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.TextBox.FilledBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"TextBox.HoverBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.TextBox.HoverBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.TextBox.HoverBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"TextBox.OutlineInactiveBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.TextBox.OutlineInactiveBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.TextBox.OutlineInactiveBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"PasswordBox.HoverBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.PasswordBox.HoverBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.PasswordBox.HoverBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"PasswordBox.Border\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.PasswordBox.Border"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.PasswordBox.Border")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"PasswordBox.OutlineBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.PasswordBox.OutlineBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.PasswordBox.OutlineBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"PasswordBox.FilledBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.PasswordBox.FilledBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.PasswordBox.FilledBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"PasswordBox.HoverBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.PasswordBox.HoverBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.PasswordBox.HoverBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"PasswordBox.OutlineInactiveBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.PasswordBox.OutlineInactiveBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.PasswordBox.OutlineInactiveBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"GridSplitter.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.GridSplitter.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.GridSplitter.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"GridSplitter.PreviewBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.GridSplitter.PreviewBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.GridSplitter.PreviewBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Header.Foreground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Header.Foreground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Header.Foreground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ListBoxItem.Border\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ListBoxItem.Border"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ListBoxItem.Border")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ListBoxItem.Selected\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ListBoxItem.Selected"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ListBoxItem.Selected")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ListView.Hover\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ListView.Hover"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ListView.Hover")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ListView.Selected\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ListView.Selected"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ListView.Selected")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ListView.Separator\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ListView.Separator"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ListView.Separator")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"RadioButton.Border\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.RadioButton.Border"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.RadioButton.Border")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"RadioButton.Checked\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.RadioButton.Checked"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.RadioButton.Checked")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"RadioButton.Disabled\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.RadioButton.Disabled"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.RadioButton.Disabled")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"RadioButton.Outline\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.RadioButton.Outline"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.RadioButton.Outline")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"RadioButton.Chip.CheckedBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.RadioButton.Chip.CheckedBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.RadioButton.Chip.CheckedBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ScrollBar.ActiveBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ScrollBar.ActiveBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ScrollBar.ActiveBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ScrollBar.Foreground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ScrollBar.Foreground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ScrollBar.Foreground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ScrollBar.RepeatButtonBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ScrollBar.RepeatButtonBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ScrollBar.RepeatButtonBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"Separator.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.Separator.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.Separator.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"TabControl.Divider\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.TabControl.Divider"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.TabControl.Divider")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToolBar.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToolBar.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToolBar.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToolBar.Separator\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToolBar.Separator"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToolBar.Separator")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToolBar.Thumb.Foreground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToolBar.Thumb.Foreground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToolBar.Thumb.Foreground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToolBar.Item.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToolBar.Item.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToolBar.Item.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToolBar.Item.Foreground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToolBar.Item.Foreground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToolBar.Item.Foreground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToolBar.Overflow.Border\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToolBar.Overflow.Border"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToolBar.Overflow.Border")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToggleButton.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToggleButton.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToggleButton.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToggleButton.Foreground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToggleButton.Foreground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToggleButton.Foreground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToggleButton.Switch.TrackOffBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToggleButton.Switch.TrackOffBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToggleButton.Switch.TrackOffBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"ToolTip.Background\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesign.Brush.ToolTip.Background"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesign.Brush.ToolTip.Background")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignPaper\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignPaper"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignPaper")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBody\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBody"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBody")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBodyLight\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBodyLight"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBodyLight")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignCheckBoxOff\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignCheckBoxOff"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignCheckBoxOff")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextBoxBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextBoxBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextBoxBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignValidationErrorBrush\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignValidationErrorBrush"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignValidationErrorBrush")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignFlatButtonClick\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignFlatButtonClick"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignFlatButtonClick")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignFlatButtonRipple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignFlatButtonRipple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignFlatButtonRipple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignSnackbarRipple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignSnackbarRipple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignSnackbarRipple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignFlatButtonRipple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignFlatButtonRipple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignFlatButtonRipple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignSnackbarRipple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignSnackbarRipple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignSnackbarRipple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignFlatButtonRipple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignFlatButtonRipple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignFlatButtonRipple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignSnackbarRipple\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignSnackbarRipple"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignSnackbarRipple")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignSnackbarBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignSnackbarBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignSnackbarBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignSnackbarMouseOver\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignSnackbarMouseOver"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignSnackbarMouseOver")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignCardBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignCardBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignCardBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignCheckBoxDisabled\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignCheckBoxDisabled"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignCheckBoxDisabled")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBodyLight\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBodyLight"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBodyLight")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignCheckBoxOff\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignCheckBoxOff"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignCheckBoxOff")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextBoxBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextBoxBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextBoxBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignChipBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignChipBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignChipBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBody\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBody"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBody")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBodyLight\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBodyLight"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBodyLight")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignCheckBoxOff\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignCheckBoxOff"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignCheckBoxOff")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextBoxBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextBoxBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextBoxBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignColumnHeader\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignColumnHeader"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignColumnHeader")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextAreaBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextAreaBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextAreaBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignDataGridRowHoverBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignDataGridRowHoverBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignDataGridRowHoverBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignColumnHeader\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignColumnHeader"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignColumnHeader")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextAreaBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextAreaBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextAreaBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBody\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBody"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBody")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBodyLight\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBodyLight"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBodyLight")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignCheckBoxOff\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignCheckBoxOff"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignCheckBoxOff")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextBoxBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextBoxBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextBoxBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignColumnHeader\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignColumnHeader"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignColumnHeader")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextAreaBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextAreaBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextAreaBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextFieldBoxDisabledBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextFieldBoxDisabledBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextFieldBoxDisabledBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextFieldBoxBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextFieldBoxBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextFieldBoxBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextFieldBoxHoverBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextFieldBoxHoverBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextFieldBoxHoverBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignDivider\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignDivider"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignDivider")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextAreaInactiveBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextAreaInactiveBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextAreaInactiveBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBody\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBody"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBody")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignBodyLight\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignBodyLight"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignBodyLight")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignCheckBoxOff\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignCheckBoxOff"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignCheckBoxOff")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextBoxBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextBoxBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextBoxBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignColumnHeader\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignColumnHeader"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignColumnHeader")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextAreaBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextAreaBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextAreaBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextFieldBoxBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextFieldBoxBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextFieldBoxBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextFieldBoxHoverBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextFieldBoxHoverBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextFieldBoxHoverBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignDivider\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignDivider"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignDivider")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextAreaInactiveBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextAreaInactiveBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextAreaInactiveBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignColumnHeader\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignColumnHeader"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignColumnHeader")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextAreaBorder\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextAreaBorder"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextAreaBorder")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignToolBarBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignToolBarBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignToolBarBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignTextFieldBoxHoverBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignTextFieldBoxHoverBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignTextFieldBoxHoverBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignDivider\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignDivider"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignDivider")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignToolBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignToolBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignToolBackground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignToolForeground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignToolForeground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignToolForeground")); } { IVisualElement textBlock = await panel.GetElement("[Text=\"MaterialDesignToolTipBackground\"]"); Color? textBlockBackground = await textBlock.GetBackgroundColor(); - await Assert.Equal(await GetResourceColor("MaterialDesignToolTipBackground"), textBlockBackground); + await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("MaterialDesignToolTipBackground")); } } private static IEnumerable GetBrushResourceNames() diff --git a/tests/MaterialDesignThemes.UITests/WPF/TimePickers/TimePickerTests.cs b/tests/MaterialDesignThemes.UITests/WPF/TimePickers/TimePickerTests.cs index 7210c6980e..960ed860db 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/TimePickers/TimePickerTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/TimePickers/TimePickerTests.cs @@ -8,11 +8,6 @@ namespace MaterialDesignThemes.UITests.WPF.TimePickers; public class TimePickerTests : TestBase { - public TimePickerTests(ITestOutputHelper output) - : base(output) - { - } - [Test] [Arguments(1, 1, 1)] [Arguments(2020, 8, 10)] @@ -32,7 +27,7 @@ public async Task OnTextChangedIfSelectedTimeIsNonNull_DatePartDoesNotChange(int await timePickerTextBox.SetText("1:10 AM"); var actual = await timePicker.GetSelectedTime(); - await Assert.Equal(new DateTime(year, month, day, 1, 10, 0), actual); + await Assert.That(actual).IsEqualTo(new DateTime(year, month, day, 1, 10, 0)); recorder.Success(); } @@ -59,7 +54,7 @@ public async Task OnLostFocusIfSelectedTimeIsNonNull_DatePartDoesNotChange(int y await textBox.MoveKeyboardFocus(); var actual = await timePicker.GetSelectedTime(); - await Assert.Equal(new DateTime(year, month, day, 1, 10, 0), actual); + await Assert.That(actual).IsEqualTo(new DateTime(year, month, day, 1, 10, 0)); recorder.Success(); } @@ -81,7 +76,7 @@ public async Task OnClockPickedIfSelectedTimeIsNonNull_DatePartDoesNotChange(int await timePicker.PickClock(1, 10); var actual = await timePicker.GetSelectedTime(); - await Assert.Equal(new DateTime(year, month, day, 1, 10, 0), actual); + await Assert.That(actual).IsEqualTo(new DateTime(year, month, day, 1, 10, 0)); recorder.Success(); } @@ -103,7 +98,7 @@ public async Task OnTextChangedIfSelectedTimeIsNull_DatePartWillBeToday() await timePickerTextBox.SetText("1:23 AM"); var actual = await timePicker.GetSelectedTime(); - await Assert.Equal(AdjustToday(today, actual).Add(new TimeSpan(1, 23, 0)), actual); + await Assert.That(actual).IsEqualTo(AdjustToday(today, actual).Add(new TimeSpan(1, 23, 0))); recorder.Success(); } @@ -128,7 +123,7 @@ public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday() await textBox.MoveKeyboardFocus(); var actual = await timePicker.GetSelectedTime(); - await Assert.Equal(AdjustToday(today, actual).Add(new TimeSpan(1, 23, 0)), actual); + await Assert.That(actual).IsEqualTo(AdjustToday(today, actual).Add(new TimeSpan(1, 23, 0))); recorder.Success(); } @@ -148,7 +143,7 @@ public async Task OnClockPickedIfSelectedTimeIsNull_DatePartWillBeToday() await timePicker.PickClock(1, 23); var actual = await timePicker.GetSelectedTime(); - await Assert.Equal(AdjustToday(today, actual).Add(new TimeSpan(1, 23, 0)), actual); + await Assert.That(actual).IsEqualTo(AdjustToday(today, actual).Add(new TimeSpan(1, 23, 0))); recorder.Success(); } @@ -186,7 +181,7 @@ public async Task OnLostFocusIfTimeHasBeenChanged_TextWillBeFormatted(string tex await textBox.MoveKeyboardFocus(); var actual = await timePickerTextBox.GetText(); - await Assert.Equal("1:02 AM", actual); + await Assert.That(actual).IsEqualTo("1:02 AM"); recorder.Success(); } @@ -214,7 +209,7 @@ public async Task OnLostFocusIfTimeHasNotBeenChanged_TextWillBeFormatted(string await textBox.MoveKeyboardFocus(); var actual = await timePickerTextBox.GetText(); - await Assert.Equal("1:02 AM", actual); + await Assert.That(actual).IsEqualTo("1:02 AM"); recorder.Success(); } @@ -239,7 +234,7 @@ public async Task OnEnterKeyDownIfTimeHasNotBeenChanged_TextWillBeFormatted(stri await timePickerTextBox.SendKeyboardInput($"{text}{Key.Enter}"); var actual = await timePickerTextBox.GetText(); - await Assert.Equal("1:02 AM", actual); + await Assert.That(actual).IsEqualTo("1:02 AM"); recorder.Success(); } @@ -264,7 +259,7 @@ public async Task OnEnterKeyDownIfTimeHasBeenChanged_TextWillBeFormatted(string await timePickerTextBox.SendKeyboardInput($"{text}{Key.Enter}"); var actual = await timePickerTextBox.GetText(); - await Assert.Equal("1:02 AM", actual); + await Assert.That(actual).IsEqualTo("1:02 AM"); recorder.Success(); } @@ -290,7 +285,7 @@ public async Task OnTimePickedIfTimeHasBeenChanged_TextWillBeFormatted(string te await timePicker.PickClock(1, 3); var actual = await timePickerTextBox.GetText(); - await Assert.Equal("1:03 AM", actual); + await Assert.That(actual).IsEqualTo("1:03 AM"); recorder.Success(); } @@ -316,7 +311,7 @@ public async Task OnTimePickedIfTimeHasNotBeenChanged_TextWillBeFormatted(string await timePicker.PickClock(1, 2); var actual = await timePickerTextBox.GetText(); - await Assert.Equal("1:02 AM", actual); + await Assert.That(actual).IsEqualTo("1:02 AM"); recorder.Success(); } @@ -337,7 +332,7 @@ public async Task OnTimePickerHelperTextFontSize_ChangesHelperTextFontSize() double fontSize = await helpTextBlock.GetFontSize(); - await Assert.Equal(20, fontSize); + await Assert.That(fontSize).IsEqualTo(20); recorder.Success(); } @@ -388,10 +383,10 @@ public async Task OutlinedTimePicker_RespectsActiveAndInactiveBorderThickness_Wh var withErrorBorderThickness = await textBoxOuterBorder.GetBorderThickness(); ; // Assert - await Assert.Equal(expectedInactiveBorderThickness, inactiveBorderThickness); - await Assert.Equal(expectedActiveBorderThickness, hoverBorderThickness); - await Assert.Equal(expectedActiveBorderThickness, focusedBorderThickness); - await Assert.Equal(expectedActiveBorderThickness, withErrorBorderThickness); + await Assert.That(inactiveBorderThickness).IsEqualTo(expectedInactiveBorderThickness); + await Assert.That(hoverBorderThickness).IsEqualTo(expectedActiveBorderThickness); + await Assert.That(focusedBorderThickness).IsEqualTo(expectedActiveBorderThickness); + await Assert.That(withErrorBorderThickness).IsEqualTo(expectedActiveBorderThickness); recorder.Success(); } @@ -431,8 +426,8 @@ public async Task TimePicker_WithHintAndHelperText_RespectsPadding(string styleN Rect? hintCoordinates = await hint.GetCoordinates(); Rect? helperTextCoordinates = await helperText.GetCoordinates(); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left), 0, tolerance); - await 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(); } @@ -480,8 +475,8 @@ public async Task TimePicker_WithHintAndValidationError_RespectsPadding(string s Rect? hintCoordinates = await hint.GetCoordinates(); Rect? errorViewerCoordinates = await errorViewer.GetCoordinates(); - await Assert.InRange(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left), 0, tolerance); - await 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(); } @@ -501,14 +496,14 @@ public async Task TimePicker_WithClearButton_ClearButtonClearsSelectedTime() "); var timePicker = await stackPanel.GetElement("/TimePicker"); var clearButton = await timePicker.GetElement