diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml
index 851278a9dc..389c02a410 100644
--- a/.github/workflows/build_artifacts.yml
+++ b/.github/workflows/build_artifacts.yml
@@ -54,7 +54,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Screenshots-${{ github.run_number }}
- path: ${{ github.workspace }}tests\MaterialDesignThemes.UITests\bin\${{ inputs.build-configuration }}\net8.0-windows7\Screenshots
+ path: ${{ github.workspace }}\tests\MaterialDesignThemes.UITests\bin\${{ inputs.build-configuration }}\net9.0-windows\Screenshots
if-no-files-found: ignore
- name: Build NuGets
diff --git a/Directory.packages.props b/Directory.packages.props
index 8fa27d2bfd..37ca871f37 100644
--- a/Directory.packages.props
+++ b/Directory.packages.props
@@ -1,9 +1,9 @@
-
+
-
+
@@ -14,7 +14,7 @@
-
+
@@ -24,11 +24,10 @@
+
+
-
-
-
-
+
diff --git a/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/src/MaterialDesignThemes.Wpf/DialogHost.cs b/src/MaterialDesignThemes.Wpf/DialogHost.cs
index 2a3bd59f77..a1b31e2e9c 100644
--- a/src/MaterialDesignThemes.Wpf/DialogHost.cs
+++ b/src/MaterialDesignThemes.Wpf/DialogHost.cs
@@ -50,7 +50,7 @@ public class DialogHost : ContentControl
///
public static readonly RoutedCommand CloseDialogCommand = new();
- private static readonly HashSet> LoadedInstances = new();
+ private static readonly HashSet> LoadedInstances = [];
private DialogOpenedEventHandler? _asyncShowOpenedEventHandler;
private DialogClosingEventHandler? _asyncShowClosingEventHandler;
@@ -221,7 +221,7 @@ private static DialogHost GetInstance(object? dialogIdentifier)
if (LoadedInstances.Count == 0)
throw new InvalidOperationException("No loaded DialogHost instances.");
- List targets = new();
+ List targets = [];
foreach (var instance in LoadedInstances.ToList())
{
if (instance.TryGetTarget(out DialogHost? dialogInstance))
diff --git a/src/MaterialDesignThemes.Wpf/Internal/TreeListViewItemsCollection.cs b/src/MaterialDesignThemes.Wpf/Internal/TreeListViewItemsCollection.cs
index 324e1c1b69..0405bf0498 100644
--- a/src/MaterialDesignThemes.Wpf/Internal/TreeListViewItemsCollection.cs
+++ b/src/MaterialDesignThemes.Wpf/Internal/TreeListViewItemsCollection.cs
@@ -6,8 +6,8 @@ namespace MaterialDesignThemes.Wpf.Internal;
public class TreeListViewItemsCollection : ObservableCollection
public const double MinimumContrastLargeText = 3.0;
- public static void AssertContrastRatio(Color foreground, Color background, double minimumContrastRatio)
+ public static async Task AssertContrastRatio(Color foreground, Color background, double minimumContrastRatio)
{
const double tolerance = 0.1;
- var ratio = ColorAssist.ContrastRatio(foreground, background);
- Assert.True(ratio >= minimumContrastRatio - tolerance, $"Contrast ratio '{ratio}' is less than {minimumContrastRatio} with a tolerance of 0.1");
+ double ratio = ColorAssist.ContrastRatio(foreground, background);
+ await Assert.That(ratio).IsGreaterThanOrEqualTo(minimumContrastRatio - tolerance)
+ .Because($"Contrast ratio '{ratio}' is less than {minimumContrastRatio} with a tolerance of 0.1");
}
}
diff --git a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj
index 2612cc5af3..8e78308ec4 100644
--- a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj
+++ b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj
@@ -6,6 +6,9 @@
true
$(NoWarn);CA1707
true
+ true
+ Exe
+ true
@@ -19,18 +22,13 @@
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
-
-
diff --git a/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs b/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs
index 719ead86b2..6d830021a8 100644
--- a/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs
+++ b/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs
@@ -1,6 +1,6 @@
using System.Collections;
using System.ComponentModel;
-using System.ComponentModel.DataAnnotations;
+using System.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@@ -46,7 +46,7 @@ private async Task CauseErrors()
{
Error = "Some error";
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Text)));
- await Task.Delay(100);
+ await Task.Delay(100, CancellationToken.None);
Error += " + more";
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Text)));
}
diff --git a/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs b/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs
new file mode 100644
index 0000000000..1ae6934500
--- /dev/null
+++ b/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs
@@ -0,0 +1,51 @@
+using System.Numerics;
+using System.Runtime.CompilerServices;
+using TUnit.Assertions.AssertConditions;
+using TUnit.Assertions.AssertConditions.Interfaces;
+using TUnit.Assertions.AssertionBuilders;
+
+namespace MaterialDesignThemes.Tests.TUnit;
+
+public static class IsCloseToExtensions
+{
+ public static IsCloseToWrapper IsCloseTo(this IValueSource valueSource, double expected, double precision, [CallerArgumentExpression(nameof(expected))] string? doNotPopulateThisValue1 = null, [CallerArgumentExpression(nameof(precision))] string? doNotPopulateThisValue2 = null)
+ {
+ var assertionBuilder = valueSource.RegisterAssertion(new IsCloseToCondition(expected, precision)
+ , [doNotPopulateThisValue1, doNotPopulateThisValue2]);
+
+ return new IsCloseToWrapper(assertionBuilder);
+ }
+
+ public static IsCloseToWrapper IsCloseTo(this IValueSource valueSource, float expected, float precision, [CallerArgumentExpression(nameof(expected))] string? doNotPopulateThisValue1 = null, [CallerArgumentExpression(nameof(precision))] string? doNotPopulateThisValue2 = null)
+ {
+ var assertionBuilder = valueSource.RegisterAssertion(new IsCloseToCondition(expected, precision)
+ , [doNotPopulateThisValue1, doNotPopulateThisValue2]);
+
+ return new IsCloseToWrapper(assertionBuilder);
+ }
+}
+
+public class IsCloseToWrapper(InvokableAssertionBuilder invokableAssertionBuilder)
+ : InvokableValueAssertionBuilder(invokableAssertionBuilder);
+
+file class IsCloseToCondition(TActual expected, TActual tolerance) : BaseAssertCondition
+ where TActual :
+ IFloatingPoint,
+ INumberBase
+{
+ protected override string GetExpectation() => $"to be within {tolerance} of {expected}";
+
+ protected override ValueTask GetResult(
+ TActual? actualValue, Exception? exception,
+ AssertionMetadata assertionMetadata
+ )
+ {
+ if(actualValue is null)
+ return AssertionResult.Fail("received null");
+
+ TActual difference = actualValue - expected;
+ TActual absoluteDifference = TActual.Abs(difference);
+ bool isInRange = absoluteDifference <= tolerance;
+ return AssertionResult.FailIf(!isInRange, $"received {actualValue}");
+ }
+}
diff --git a/tests/MaterialDesignThemes.UITests/TestBase.cs b/tests/MaterialDesignThemes.UITests/TestBase.cs
index 66615f971c..e2aeac2535 100644
--- a/tests/MaterialDesignThemes.UITests/TestBase.cs
+++ b/tests/MaterialDesignThemes.UITests/TestBase.cs
@@ -1,7 +1,10 @@
using System.Diagnostics.CodeAnalysis;
using System.Windows.Media;
+using MaterialDesignThemes.UITests;
+using TUnit.Core.Interfaces;
+
+[assembly: ParallelLimiter]
-[assembly: CollectionBehavior(DisableTestParallelization = true)]
[assembly: GenerateHelpers(typeof(AutoSuggestBox))]
[assembly: GenerateHelpers(typeof(ColorPicker))]
[assembly: GenerateHelpers(typeof(DecimalUpDown))]
@@ -16,10 +19,15 @@
namespace MaterialDesignThemes.UITests;
-public abstract class TestBase(ITestOutputHelper output) : IAsyncLifetime
+public record SingleParallelLimit : IParallelLimit
+{
+ public int Limit => 1;
+}
+
+public abstract class TestBase()
{
protected bool AttachedDebuggerToRemoteProcess { get; set; } = true;
- protected ITestOutputHelper Output { get; } = output ?? throw new ArgumentNullException(nameof(output));
+ protected static TextWriter Output => TestContext.Current?.OutputWriter ?? throw new InvalidOperationException("Could not find output writer");
[NotNull]
protected IApp? App { get; set; }
@@ -46,7 +54,8 @@ protected async Task LoadUserControl(Type userControlType)
return await App.CreateWindowWithUserControl(userControlType);
}
- public async Task InitializeAsync() =>
+ [Before(Test)]
+ public async ValueTask InitializeAsync() =>
App = await XamlTest.App.StartRemote(new AppOptions
{
#if !DEBUG
@@ -55,5 +64,7 @@ public async Task InitializeAsync() =>
AllowVisualStudioDebuggerAttach = AttachedDebuggerToRemoteProcess,
LogMessage = Output.WriteLine
});
- public async Task DisposeAsync() => await App.DisposeAsync();
+
+ [After(Test)]
+ public async ValueTask DisposeAsync() => await App.DisposeAsync();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs
index 59e2fc3f75..f1302b56bf 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs
@@ -1,19 +1,17 @@
using System.ComponentModel;
using MaterialDesignThemes.UITests.Samples.AutoSuggestBoxes;
using MaterialDesignThemes.UITests.Samples.AutoSuggestTextBoxes;
-using Xunit.Sdk;
-
+using TUnit.Core.Exceptions;
namespace MaterialDesignThemes.UITests.WPF.AutoSuggestBoxes;
public class AutoSuggestBoxTests : TestBase
{
- public AutoSuggestBoxTests(ITestOutputHelper output)
- : base(output)
+ public AutoSuggestBoxTests()
{
- AttachedDebuggerToRemoteProcess = true;
+ AttachedDebuggerToRemoteProcess = false;
}
- [Fact]
+ [Test]
public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggestions()
{
await using var recorder = new TestRecorder(App);
@@ -29,8 +27,8 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti
//Assert
- Assert.True(await suggestBox.GetIsSuggestionOpen());
- Assert.True(await popup.GetIsOpen());
+ await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue();
+ await Assert.That(await popup.GetIsOpen()).IsTrue();
//Validates these elements are found
await AssertExists(suggestionListBox, "Bananas");
@@ -44,7 +42,7 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti
recorder.Success();
}
- [Fact]
+ [Test]
public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated()
{
await using var recorder = new TestRecorder(App);
@@ -59,8 +57,8 @@ public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated()
await suggestBox.SendInput(new KeyboardInput("B"));
//Assert
- Assert.True(await suggestBox.GetIsSuggestionOpen());
- Assert.True(await popup.GetIsOpen());
+ await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue();
+ await Assert.That(await popup.GetIsOpen()).IsTrue();
double? lastHeight = null;
await Wait.For(async () =>
@@ -71,7 +69,7 @@ await Wait.For(async () =>
lastHeight = currentHeight;
if (!rv)
{
- await Task.Delay(100);
+ await Task.Delay(100, TestContext.Current!.CancellationToken);
}
return rv;
});
@@ -82,16 +80,16 @@ await Wait.For(async () =>
await bananas.LeftClick();
// Wait for the text to be updated
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current!.CancellationToken);
var suggestBoxText = await suggestBox.GetText();
//Validate that the current text is the same as the selected item
- Assert.Equal("Bananas", suggestBoxText);
+ await Assert.That(suggestBoxText).IsEqualTo("Bananas");
recorder.Success();
}
- [Fact]
+ [Test]
public async Task CanFilterItems_WithCollectionView_FiltersSuggestions()
{
await using var recorder = new TestRecorder(App);
@@ -108,8 +106,8 @@ public async Task CanFilterItems_WithCollectionView_FiltersSuggestions()
//Assert
- Assert.True(await suggestBox.GetIsSuggestionOpen());
- Assert.True(await popup.GetIsOpen());
+ await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue();
+ await Assert.That(await popup.GetIsOpen()).IsTrue();
//Validates these elements are found
await AssertExists(suggestionListBox, "Bananas");
@@ -123,7 +121,7 @@ public async Task CanFilterItems_WithCollectionView_FiltersSuggestions()
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 3761")]
public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed()
{
@@ -144,22 +142,22 @@ public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed()
// Act
await suggestBox.MoveKeyboardFocus();
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current!.CancellationToken);
await suggestBox.SendInput(new KeyboardInput("B")); // Open the popup
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current.CancellationToken);
await suggestBox.SendInput(new KeyboardInput(Key.Escape)); // Close the popup
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current.CancellationToken);
await suggestBox.SendInput(new KeyboardInput(Key.Tab)); // Press TAB to focus the next element
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current.CancellationToken);
// Assert
- Assert.False(await suggestBox.GetIsFocused());
- Assert.True(await nextTextBox.GetIsFocused());
+ await Assert.That(await suggestBox.GetIsFocused()).IsFalse();
+ await Assert.That(await nextTextBox.GetIsFocused()).IsTrue();
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 3815")]
public async Task AutoSuggestBox_KeysUpAndDown_WrapAround()
{
@@ -175,7 +173,7 @@ public async Task AutoSuggestBox_KeysUpAndDown_WrapAround()
//Act & Assert
await suggestBox.MoveKeyboardFocus();
await suggestBox.SendInput(new KeyboardInput("e"));
- await Task.Delay(delay);
+ await Task.Delay(delay, TestContext.Current!.CancellationToken);
static int? GetSuggestionCount(AutoSuggestBox autoSuggestBox)
{
@@ -187,20 +185,22 @@ public async Task AutoSuggestBox_KeysUpAndDown_WrapAround()
//Assert that initially the first item is selected
int selectedIndex = await suggestionListBox.GetSelectedIndex();
- Assert.Equal(0, selectedIndex);
- await Task.Delay(delay);
+ await Assert.That(selectedIndex).IsEqualTo(0);
+ await Task.Delay(delay, TestContext.Current.CancellationToken);
//Assert that the last item is selected after pressing ArrowUp
await suggestBox.SendInput(new KeyboardInput(Key.Up));
- Assert.Equal(itemCount - 1, await suggestionListBox.GetSelectedIndex());
- await Task.Delay(delay);
+ await Assert.That(await suggestionListBox.GetSelectedIndex()).IsEqualTo(itemCount - 1);
+ await Task.Delay(delay, TestContext.Current.CancellationToken);
//Assert that the first item is selected after pressing ArrowDown
await suggestBox.SendInput(new KeyboardInput(Key.Down));
- Assert.Equal(0, await suggestionListBox.GetSelectedIndex());
+ await Assert.That(await suggestionListBox.GetSelectedIndex()).IsEqualTo(0);
+
+ recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 3845")]
public async Task AutoSuggestBox_SelectingAnItem_SetsSelectedItem()
{
@@ -220,12 +220,12 @@ public async Task AutoSuggestBox_SelectingAnItem_SetsSelectedItem()
//Assert
string? selectedItem = (await suggestBox.GetSelectedItem()) as string;
- Assert.Equal("Bananas", selectedItem);
+ await Assert.That(selectedItem).IsEqualTo("Bananas");
- static void AssertViewModelProperty(AutoSuggestBox autoSuggestBox)
+ static async Task AssertViewModelProperty(AutoSuggestBox autoSuggestBox)
{
var viewModel = (AutoSuggestTextBoxWithCollectionViewViewModel)autoSuggestBox.DataContext;
- Assert.Equal("Bananas", viewModel.SelectedItem);
+ await Assert.That(viewModel.SelectedItem).IsEqualTo("Bananas");
}
await suggestBox.RemoteExecute(AssertViewModelProperty);
@@ -237,11 +237,11 @@ private static async Task AssertExists(IVisualElement suggestionListBox
try
{
_ = await suggestionListBox.GetElement(ElementQuery.PropertyExpression(x => x.Text, text));
- Assert.True(existsOrNotCheck);
+ await Assert.That(existsOrNotCheck).IsTrue();
}
- catch (Exception e) when (e is not TrueException)
+ catch (Exception e) when (e is not TUnitException)
{
- Assert.False(existsOrNotCheck);
+ await Assert.That(existsOrNotCheck).IsFalse();
}
}
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs
index 1718fcc834..312ab51d28 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs
@@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Buttons;
public class OutlineButtonTests : TestBase
{
- public OutlineButtonTests(ITestOutputHelper output)
- : base(output)
- { }
-
- [Fact]
+ [Test]
public async Task OutlinedButton_UsesThemeColorForBorder()
{
await using var recorder = new TestRecorder(App);
@@ -24,13 +20,13 @@ public async Task OutlinedButton_UsesThemeColorForBorder()
Color? internalBorderColor = await internalBorder.GetBorderBrushColor();
//Assert
- Assert.Equal(midColor, borderColor);
- Assert.Equal(midColor, internalBorderColor);
+ await Assert.That(borderColor).IsEqualTo(midColor);
+ await Assert.That(internalBorderColor).IsEqualTo(midColor);
recorder.Success();
}
- [Fact]
+ [Test]
public async Task OutlinedButton_BorderCanBeOverridden()
{
await using var recorder = new TestRecorder(App);
@@ -50,13 +46,13 @@ public async Task OutlinedButton_BorderCanBeOverridden()
Color? borderBrush = await internalBorder.GetBorderBrushColor();
//Assert
- Assert.Equal(new Thickness(5), borderThickness);
- Assert.Equal(Colors.Red, borderBrush);
+ await Assert.That(borderThickness).IsEqualTo(new Thickness(5));
+ await Assert.That(borderBrush).IsEqualTo(Colors.Red);
recorder.Success();
}
- [Fact]
+ [Test]
public async Task OutlinedButton_OnMouseOver_UsesThemeBrush()
{
await using var recorder = new TestRecorder(App);
@@ -74,7 +70,7 @@ await Wait.For(async () =>
SolidColorBrush? internalBorderBackground = (await internalBorder.GetBackground()) as SolidColorBrush;
//Assert
- Assert.Equal(midColor, internalBorderBackground?.Color);
+ await Assert.That(internalBorderBackground?.Color).IsEqualTo(midColor);
});
recorder.Success();
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs
index c0ed522aec..39c7b3ea7a 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs
@@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Buttons;
public class RaisedButtonTests : TestBase
{
- public RaisedButtonTests(ITestOutputHelper output)
- : base(output)
- { }
-
- [Fact]
+ [Test]
public async Task OnLoad_ThemeBrushesSet()
{
await using var recorder = new TestRecorder(App);
@@ -21,7 +17,7 @@ public async Task OnLoad_ThemeBrushesSet()
Color? color = await button.GetBackgroundColor();
//Assert
- Assert.Equal(midColor, color);
+ await Assert.That(color).IsEqualTo(midColor);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs
index f30f158a9e..1187395aee 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs
@@ -1,12 +1,11 @@
-namespace MaterialDesignThemes.UITests.WPF.Cards;
+
+
+namespace MaterialDesignThemes.UITests.WPF.Cards;
public class ElevatedCardTests : TestBase
{
- public ElevatedCardTests(ITestOutputHelper output)
- : base(output)
- { }
- [Fact]
+ [Test]
public async Task ElevatedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnBorder()
{
await using var recorder = new TestRecorder(App);
@@ -20,10 +19,10 @@ public async Task ElevatedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnB
CornerRadius? internalBorderCornerRadius = await internalBorder.GetCornerRadius();
//Assert
- Assert.Equal(5, internalBorderCornerRadius.Value.TopLeft);
- Assert.Equal(5, internalBorderCornerRadius.Value.TopRight);
- Assert.Equal(5, internalBorderCornerRadius.Value.BottomRight);
- Assert.Equal(5, internalBorderCornerRadius.Value.BottomLeft);
+ await Assert.That(internalBorderCornerRadius.Value.TopLeft).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.TopRight).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.BottomRight).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.BottomLeft).IsEqualTo(5);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs
index 424cbaf138..15da509acc 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs
@@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Cards;
public class OutlinedCardTests : TestBase
{
- public OutlinedCardTests(ITestOutputHelper output)
- : base(output)
- { }
-
- [Fact]
+ [Test]
public async Task OutlinedCard_UsesThemeColorForBorder()
{
await using var recorder = new TestRecorder(App);
@@ -23,12 +19,12 @@ public async Task OutlinedCard_UsesThemeColorForBorder()
Color? internalBorderColor = await internalBorder.GetBorderBrushColor();
//Assert
- Assert.Equal(dividerColor, internalBorderColor);
+ await Assert.That(internalBorderColor).IsEqualTo(dividerColor);
recorder.Success();
}
- [Fact]
+ [Test]
public async Task OutlinedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnBorder()
{
await using var recorder = new TestRecorder(App);
@@ -42,10 +38,10 @@ public async Task OutlinedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnB
CornerRadius? internalBorderCornerRadius = await internalBorder.GetCornerRadius();
//Assert
- Assert.Equal(5, internalBorderCornerRadius.Value.TopLeft);
- Assert.Equal(5, internalBorderCornerRadius.Value.TopRight);
- Assert.Equal(5, internalBorderCornerRadius.Value.BottomRight);
- Assert.Equal(5, internalBorderCornerRadius.Value.BottomLeft);
+ await Assert.That(internalBorderCornerRadius.Value.TopLeft).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.TopRight).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.BottomRight).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.BottomLeft).IsEqualTo(5);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs
index 57805e8a1c..922a0b5cd8 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs
@@ -5,12 +5,7 @@ namespace MaterialDesignThemes.UITests.WPF;
public class ColorPickerTests : TestBase
{
- public ColorPickerTests(ITestOutputHelper output)
- : base(output)
- {
- }
-
- [Fact]
+ [Test]
public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday()
{
await using var recorder = new TestRecorder(App);
@@ -29,12 +24,12 @@ public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday()
await thumb.SendInput(MouseInput.MoveRelative(xOffset: -5, yOffset: -10));
await thumb.SendInput(MouseInput.LeftDown());
await thumb.SendInput(MouseInput.MoveRelative(yOffset: 25));
- await Task.Delay(100);
+ await Task.Delay(100, TestContext.Current!.CancellationToken);
await thumb.SendInput(MouseInput.LeftUp());
double currentBrightness = (await colorPicker.GetColor()).ToHsb().Brightness;
- Assert.True(currentBrightness < lastBrightness, $"Brightness {currentBrightness} is not less than {lastBrightness}");
+ await Assert.That(currentBrightness).IsLessThan(lastBrightness);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs
index 6422947496..bc8dca69ca 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs
@@ -1,26 +1,21 @@
using System.Windows.Media;
+
namespace MaterialDesignThemes.UITests.WPF.ColorZones;
public class ColorZoneTests : TestBase
{
- public ColorZoneTests(ITestOutputHelper output)
- : base(output)
- {
-
- }
-
- [Theory]
- [InlineData(ColorZoneMode.Standard, "MaterialDesign.Brush.Background", "MaterialDesign.Brush.Foreground")]
- [InlineData(ColorZoneMode.Inverted, "MaterialDesign.Brush.Foreground", "MaterialDesign.Brush.Background")]
- [InlineData(ColorZoneMode.PrimaryLight, "MaterialDesign.Brush.Primary.Light", "MaterialDesign.Brush.Primary.Light.Foreground")]
- [InlineData(ColorZoneMode.PrimaryMid, "MaterialDesign.Brush.Primary", "MaterialDesign.Brush.Primary.Foreground")]
- [InlineData(ColorZoneMode.PrimaryDark, "MaterialDesign.Brush.Primary.Dark", "MaterialDesign.Brush.Primary.Dark.Foreground")]
- [InlineData(ColorZoneMode.SecondaryLight, "MaterialDesign.Brush.Secondary.Light", "MaterialDesign.Brush.Secondary.Light.Foreground")]
- [InlineData(ColorZoneMode.SecondaryMid, "MaterialDesign.Brush.Secondary", "MaterialDesign.Brush.Secondary.Foreground")]
- [InlineData(ColorZoneMode.SecondaryDark, "MaterialDesign.Brush.Secondary.Dark", "MaterialDesign.Brush.Secondary.Dark.Foreground")]
- [InlineData(ColorZoneMode.Light, "MaterialDesign.Brush.ColorZone.LightBackground", "MaterialDesign.Brush.ColorZone.LightForeground")]
- [InlineData(ColorZoneMode.Dark, "MaterialDesign.Brush.ColorZone.DarkBackground", "MaterialDesign.Brush.ColorZone.DarkForeground")]
+ [Test]
+ [Arguments(ColorZoneMode.Standard, "MaterialDesign.Brush.Background", "MaterialDesign.Brush.Foreground")]
+ [Arguments(ColorZoneMode.Inverted, "MaterialDesign.Brush.Foreground", "MaterialDesign.Brush.Background")]
+ [Arguments(ColorZoneMode.PrimaryLight, "MaterialDesign.Brush.Primary.Light", "MaterialDesign.Brush.Primary.Light.Foreground")]
+ [Arguments(ColorZoneMode.PrimaryMid, "MaterialDesign.Brush.Primary", "MaterialDesign.Brush.Primary.Foreground")]
+ [Arguments(ColorZoneMode.PrimaryDark, "MaterialDesign.Brush.Primary.Dark", "MaterialDesign.Brush.Primary.Dark.Foreground")]
+ [Arguments(ColorZoneMode.SecondaryLight, "MaterialDesign.Brush.Secondary.Light", "MaterialDesign.Brush.Secondary.Light.Foreground")]
+ [Arguments(ColorZoneMode.SecondaryMid, "MaterialDesign.Brush.Secondary", "MaterialDesign.Brush.Secondary.Foreground")]
+ [Arguments(ColorZoneMode.SecondaryDark, "MaterialDesign.Brush.Secondary.Dark", "MaterialDesign.Brush.Secondary.Dark.Foreground")]
+ [Arguments(ColorZoneMode.Light, "MaterialDesign.Brush.ColorZone.LightBackground", "MaterialDesign.Brush.ColorZone.LightForeground")]
+ [Arguments(ColorZoneMode.Dark, "MaterialDesign.Brush.ColorZone.DarkBackground", "MaterialDesign.Brush.ColorZone.DarkForeground")]
public async Task Mode_SetsThemeColors(ColorZoneMode mode, string backgroundBrush, string foregroundBrush)
{
await using var recorder = new TestRecorder(App);
@@ -31,8 +26,8 @@ public async Task Mode_SetsThemeColors(ColorZoneMode mode, string backgroundBrus
Color background = await GetThemeColor(backgroundBrush);
Color foreground = await GetThemeColor(foregroundBrush);
- Assert.Equal(background, await colorZone.GetBackgroundColor());
- Assert.Equal(foreground, await colorZone.GetForegroundColor());
+ await Assert.That(await colorZone.GetBackgroundColor()).IsEqualTo(background);
+ await Assert.That(await colorZone.GetForegroundColor()).IsEqualTo(foreground);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
index d081596312..1510cf2b05 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
@@ -5,12 +5,7 @@ namespace MaterialDesignThemes.UITests.WPF.ComboBoxes;
public class ComboBoxTests : TestBase
{
- public ComboBoxTests(ITestOutputHelper output)
- : base(output)
- {
- }
-
- [Fact]
+ [Test]
[Description("Pull Request 2192")]
public async Task OnComboBoxHelperTextFontSize_ChangesHelperTextFontSize()
{
@@ -26,11 +21,11 @@ public async Task OnComboBoxHelperTextFontSize_ChangesHelperTextFontSize()
double fontSize = await helpTextBlock.GetFontSize();
- Assert.Equal(20, fontSize);
+ await Assert.That(fontSize).IsEqualTo(20);
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Pull Request 2192")]
public async Task OnFilledComboBoxHelperTextFontSize_ChangesHelperTextFontSize()
{
@@ -47,11 +42,11 @@ public async Task OnFilledComboBoxHelperTextFontSize_ChangesHelperTextFontSize()
double fontSize = await helpTextBlock.GetFontSize();
- Assert.Equal(20, fontSize);
+ await Assert.That(fontSize).IsEqualTo(20);
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 2495")]
public async Task OnComboBox_WithClearButton_ClearsSelection()
{
@@ -74,23 +69,23 @@ public async Task OnComboBox_WithClearButton_ClearsSelection()
int? selectedIndex = await comboBox.GetSelectedIndex();
object? text = await comboBox.GetText();
- Assert.True(selectedIndex >= 0);
- Assert.NotNull(text);
+ await Assert.That(selectedIndex >= 0).IsTrue();
+ await Assert.That(text).IsNotNull();
await clearButton.LeftClick();
await Wait.For(async () =>
{
text = await comboBox.GetText();
- Assert.Null(text);
+ await Assert.That(text).IsNull();
selectedIndex = await comboBox.GetSelectedIndex();
- Assert.False(selectedIndex >= 0);
+ await Assert.That(selectedIndex >= 0).IsFalse();
});
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 2690")]
public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste()
{
@@ -108,7 +103,7 @@ public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste()
await comboBox.RightClick();
IVisualElement? contextMenu = await comboBox.GetContextMenu();
- Assert.True(contextMenu is not null, "No context menu set on the ComboBox");
+ await Assert.That(contextMenu).IsNotNull().Because("No context menu set on the ComboBox");
await Wait.For(async () => await contextMenu!.GetIsVisible());
await AssertMenu("Cut");
await AssertMenu("Copy");
@@ -119,11 +114,11 @@ public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste()
async Task AssertMenu(string menuHeader)
{
var menuItem = await contextMenu!.GetElement(ElementQuery.PropertyExpression