Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f9123cf
Updating to xUnit v3 1.x
Keboo Mar 7, 2025
86ee7ba
Adding MTP
Keboo Mar 7, 2025
35dd15d
Starting conversion to TUnit
Keboo Mar 7, 2025
0896401
Tests all compile
Keboo Mar 14, 2025
b025312
Adds cancellation tokens to async delays
Keboo Apr 25, 2025
857fcf0
WIP
Keboo Apr 25, 2025
d90b472
Refactors test suite and updates dependencies
Keboo May 9, 2025
6090704
Updates test framework and fixes assertions
Keboo May 30, 2025
5feeb41
Reverting stupid
Keboo May 30, 2025
a9cfce8
Save point
Keboo May 30, 2025
5fb172e
Assert.True
Keboo May 30, 2025
a89d951
Updates tests to be async
Keboo May 30, 2025
93c173e
Removes TUnit dependencies from tests
Keboo May 30, 2025
e92ae66
Tests are now compiling
Keboo May 30, 2025
dbf6a5b
Updates test framework for DecimalUpDown
Keboo Jun 13, 2025
b8fd9a7
Fixing member data sources
Keboo Jun 13, 2025
8eca7b3
Refactors code for brevity and adds tests
Keboo Jun 13, 2025
5b65a58
Updates screenshot artifact path
Keboo Jun 13, 2025
bd166d4
Fixes artifact upload path
Keboo Jun 20, 2025
66e3264
Updates coordinate assertion method
Keboo Jun 20, 2025
69cd173
Updates NuGet package versions
Keboo Jun 20, 2025
407f626
Fixes UI test failures
Keboo Jun 23, 2025
7b3b253
Fixes combo box test assertion
Keboo Jun 23, 2025
af69b3a
Updates artifact path for .NET 9
Keboo Jun 23, 2025
110e8bc
Adds success recorder in auto suggest box tests
Keboo Jun 23, 2025
dc9a112
Skips flaky GetDialogSession test
Keboo Jun 23, 2025
7a321dd
Skips failing saturation drag test
Keboo Jun 27, 2025
4dafa6b
Ensures DialogHost is properly unloaded
Keboo Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests are now compiling
  • Loading branch information
Keboo committed Jun 27, 2025
commit e92ae663cc24dd19d684a3a8667d819d0477fc87
2 changes: 1 addition & 1 deletion tests/MaterialDesignThemes.Wpf.Tests/ClockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task CanGenerateHoursButtonsWith24Hours()
var buttonContents = hoursCanvas.GetVisualChildren<ClockItemButton>().Select(x => x.Content.ToString());

var expected = Enumerable.Range(13, 11).Select(x => $"{x:00}")
.Concat(new[] { "00" })
.Concat(["00"])
.Concat(Enumerable.Range(1, 12).Select(x => $"{x:#}"));
await Assert.That(buttonContents.OrderBy(x => x)).IsEqualTo(expected.OrderBy(x => x));
}
Expand Down
12 changes: 6 additions & 6 deletions tests/MaterialDesignThemes.Wpf.Tests/ColorPickerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace MaterialDesignThemes.Wpf.Tests;
//TODO: Many of these tests could be moved over to MaterialDesignThemes.UITests
public class ColorPickerTests
{
private readonly ColorPicker _colorPicker;
private readonly Slider _hueSlider;
private readonly Canvas _saturationBrightnessPicker;
private readonly Thumb _saturationBrightnessPickerThumb;
private readonly ColorPicker _colorPicker = new();
private Slider _hueSlider = null!;
private Canvas _saturationBrightnessPicker = null!;
private Thumb _saturationBrightnessPickerThumb = null!;

public ColorPickerTests()
[Before(Test)]
public void Setup()
{
_colorPicker = new ColorPicker();
_colorPicker.ApplyDefaultStyle();
_colorPicker.Arrange(new Rect(0, 0, 400, 100));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using System.Globalization;
using System.Windows.Data;
using MaterialDesignThemes.Wpf.Converters;
using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests.Converters;

public sealed class MathConverterTests
{
[Test]
[EnumData]
public async Task EnumValues_AreAllHandled(MathOperation operation)
[MatrixDataSource]
public async Task EnumValues_AreAllHandled(
[EnumData<MathOperation>] MathOperation operation)
{
MathConverter converter = new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
using System.Globalization;
using MaterialDesignThemes.Wpf.Converters;
using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests.Converters;

public sealed class MathMultipleConverterTests
{
[Test]
[EnumData]
public async Task EnumValues_AreAllHandled(MathOperation operation)
[MatrixDataSource]
public async Task EnumValues_AreAllHandled(
[EnumData<MathOperation>]MathOperation operation)
{
MathMultipleConverter converter = new()
{
Expand Down
13 changes: 7 additions & 6 deletions tests/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

namespace MaterialDesignThemes.Wpf.Tests;

public class DialogHostTests : IDisposable
public class DialogHostTests
{
private readonly DialogHost _dialogHost;
private readonly DialogHost _dialogHost = new();

public DialogHostTests()
[Before(Test)]
public void Setup()
{
_dialogHost = new DialogHost();
_dialogHost.ApplyDefaultStyle();
_dialogHost.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
}

public void Dispose()
[After(Test)]
public void Cleanup()
{
_dialogHost.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent));
}
Expand Down Expand Up @@ -403,7 +404,7 @@ public async Task WhenOnlySingleDialogHostIdentifierIsNullItShowsDialog()
}

[Test, STAThreadExecutor]
public async Task GetDialogSession_ShouldAllowAccessFromMultipleUIThreads()
public void GetDialogSession_ShouldAllowAccessFromMultipleUIThreads()
{
DialogHost? dialogHost = null;
DialogHost? dialogHostOnOtherUiThread = null;
Expand Down
30 changes: 9 additions & 21 deletions tests/MaterialDesignThemes.Wpf.Tests/EnumDataAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
using System.Reflection;
namespace MaterialDesignThemes.Wpf.Tests;

namespace MaterialDesignThemes.Wpf.Tests;

public class EnumDataAttribute : DataAttribute
public class EnumDataAttribute<TEnum> : MatrixAttribute<TEnum>
where TEnum : struct, Enum
{
public override ValueTask<IReadOnlyCollection<ITheoryDataRow>> GetData(MethodInfo testMethod, DisposalTracker disposalTracker)
public EnumDataAttribute()
#if NET6_0_OR_GREATER
: base(Enum.GetValues<TEnum>())
#else
: base([.. Enum.GetValues(typeof(TEnum)).OfType<TEnum>()])
#endif
{
ParameterInfo[] parameters = testMethod.GetParameters();
if (parameters.Length != 1 ||
!parameters[0].ParameterType.IsEnum)
{
throw new Exception($"{testMethod.DeclaringType?.FullName}.{testMethod.Name} must have a single enum parameter");
}

return new([..GetDataImplementation(parameters[0].ParameterType)]);

static IEnumerable<ITheoryDataRow> GetDataImplementation(Type parameterType)
{
foreach (object enumValue in Enum.GetValues(parameterType).OfType<object>())
{
yield return new TheoryDataRow(enumValue);
}
}
}
public override bool SupportsDiscoveryEnumeration() => true;
}
4 changes: 2 additions & 2 deletions tests/MaterialDesignThemes.Wpf.Tests/FlipperAssistTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task CardStyle_StyleWithWrongTargetType_AttachedPropertyNotSet()
}

[Test, STAThreadExecutor]
public void CardStyle_StyleWithCorrectTargetType_AttachedPropertySet()
public async Task CardStyle_StyleWithCorrectTargetType_AttachedPropertySet()
{
// Arrange
var style = new Style(typeof(Card));
Expand All @@ -43,7 +43,7 @@ public void CardStyle_StyleWithCorrectTargetType_AttachedPropertySet()
}

[Test, STAThreadExecutor]
public void CardStyle_StyleWithDerivedCardTargetType_AttachedPropertySet()
public async Task CardStyle_StyleWithDerivedCardTargetType_AttachedPropertySet()
{
// Arrange
var style = new Style(typeof(DerivedCard));
Expand Down
6 changes: 3 additions & 3 deletions tests/MaterialDesignThemes.Wpf.Tests/MdixHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ static MdixHelper()

private static ResourceDictionary GenericResourceDictionary => GetResourceDictionary("Generic.xaml");

public static async Task ApplyStyle<T>(this T control, object styleKey, bool applyTemplate = true) where T : FrameworkElement
public static void ApplyStyle<T>(this T control, object styleKey, bool applyTemplate = true) where T : FrameworkElement
{
var style = GetStyle(styleKey);
await Assert.That(style).IsNotNull().Because($"Could not find style with key '{styleKey}' for control type {typeof(T).FullName}");
var style = GetStyle(styleKey) ?? throw new InvalidOperationException($"Could not find style with key '{styleKey}' for control type {typeof(T).FullName}");

control.Style = style;
if (applyTemplate)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a361c80e-f6cd-4c57-a96c-002db159c1f4")]

[assembly: CollectionBehavior(DisableTestParallelization = true)]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public async Task IsDuplicate_ThrowsOnNullArgument()
{
SnackbarMessageQueueItem item = CreateItem();
var ex = await Assert.That(() => item.IsDuplicate(null!)).ThrowsExactly<ArgumentNullException>();
await Assert.That(ex.ParamName).IsEqualTo("value");
await Assert.That(ex?.ParamName).IsEqualTo("value");
}

[Test]
Expand Down
51 changes: 0 additions & 51 deletions tests/MaterialDesignThemes.Wpf.Tests/TUnit/IsCloseToExtensions.cs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/MaterialDesignThemes.Wpf.Tests/TextBlockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public async Task DefaultVerticalAlignment_ShouldBeStretch()
foreach (var styleKey in MdixHelper.GetStyleKeysFor<TextBlock>())
{
var textBlock = new TextBlock();
await textBlock.ApplyStyle(styleKey, false);
textBlock.ApplyStyle(styleKey, false);

await Assert.That(textBlock.VerticalAlignment).IsEqualTo(VerticalAlignment.Stretch);
}
Expand Down