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
Removes TUnit dependencies from tests
Removes the TUnit library and associated code from test projects, modernizing testing using the default testing framework.
  • Loading branch information
Keboo committed Jun 27, 2025
commit 93c173ea3d27192dee8ec577374f41a929711f8c
14 changes: 7 additions & 7 deletions src/MaterialDesignThemes.Wpf/RatingBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,21 +411,21 @@ internal class TextBlockForegroundConverter : IMultiValueConverter
return new SolidColorBrush(semiTransparent);
}

GradientStopCollection CreateGradientStopCollection(Color originalColor, Color semiTransparent, double offset, bool invertDirection)
static GradientStopCollection CreateGradientStopCollection(Color originalColor, Color semiTransparent, double offset, bool invertDirection)
{
if (invertDirection)
{
return new()
{
return
[
new GradientStop {Color = semiTransparent, Offset = offset},
new GradientStop {Color = originalColor, Offset = offset},
};
];
}
return new()
{
return
[
new GradientStop {Color = originalColor, Offset = offset},
new GradientStop {Color = semiTransparent, Offset = offset}
};
];
}

// This should never happen (returning actual brush to avoid the compilers squiggly line warning)
Expand Down
23 changes: 9 additions & 14 deletions tests/MaterialDesignThemes.Wpf.Tests/CalendarFormatInfoTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System.Globalization;

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;

public class CalendarFormatInfoTests
Expand Down Expand Up @@ -56,7 +51,7 @@ public async Task TestFromCultureInfo(string cultureName, string yearMonth, stri
[Arguments("X' , 'ddd", "ddd", ",", false)]
[Arguments("Xddddd", "ddd", "", false)]
[Arguments("X,ddddd", "ddd", "", false)]
public void CanParseDayOfWeek(string s, string pattern, string separator, bool isFirst)
public async Task CanParseDayOfWeek(string s, string pattern, string separator, bool isFirst)
{
var result = CalendarFormatInfo.DayOfWeekStyle.Parse(s);

Expand All @@ -66,7 +61,7 @@ public void CanParseDayOfWeek(string s, string pattern, string separator, bool i
}

[Test, STAThreadExecutor]
public void SettingYearPattern()
public async Task SettingYearPattern()
{
const string cultureName = "en-001";
CalendarFormatInfo.SetYearPattern(cultureName, "A");
Expand All @@ -79,7 +74,7 @@ public void SettingYearPattern()
}

[Test, STAThreadExecutor]
public void SettingYearPatternOfMultipleCultures()
public async Task SettingYearPatternOfMultipleCultures()
{
string[] cultureNames = { "en-001", "en-150" };
CalendarFormatInfo.SetYearPattern(cultureNames, "B");
Expand All @@ -91,7 +86,7 @@ public void SettingYearPatternOfMultipleCultures()
}

[Test, STAThreadExecutor]
public void SettingDayOfWeekStyle()
public async Task SettingDayOfWeekStyle()
{
const string cultureName = "en-001";
CalendarFormatInfo.SetDayOfWeekStyle(cultureName, new CalendarFormatInfo.DayOfWeekStyle("Z", "@", true));
Expand All @@ -106,7 +101,7 @@ public void SettingDayOfWeekStyle()
}

[Test, STAThreadExecutor]
public void SettingDayOfWeekStyleOfMultipleCultures()
public async Task SettingDayOfWeekStyleOfMultipleCultures()
{
string[] cultureNames = { "en-001", "en-150" };
CalendarFormatInfo.SetDayOfWeekStyle(cultureNames, new CalendarFormatInfo.DayOfWeekStyle("Z", "@", true));
Expand All @@ -119,18 +114,18 @@ public void SettingDayOfWeekStyleOfMultipleCultures()
}

[Test, STAThreadExecutor]
public void ResettingDayOfWeekStyle()
public async Task ResettingDayOfWeekStyle()
{
const string cultureName = "en-001";
CalendarFormatInfo.SetDayOfWeekStyle(cultureName, new CalendarFormatInfo.DayOfWeekStyle("Z", "@", true));
CalendarFormatInfo.ResetDayOfWeekStyle(cultureName);
var result = CalendarFormatInfo.FromCultureInfo(CultureInfo.GetCultureInfo(cultureName));
await Assert.That(result.ComponentOnePattern).IsEqualTo("d MMM");
await Assert.That(", result.ComponentTwoPattern).IsEqualTo("ddd);
await Assert.That(result.ComponentTwoPattern).IsEqualTo("ddd");
}

[Test, STAThreadExecutor]
public void ResettingDayOfWeekStyleOfMultipleCultures()
public async Task ResettingDayOfWeekStyleOfMultipleCultures()
{
string[] cultureNames = { "en-001", "en-150" };
CalendarFormatInfo.SetDayOfWeekStyle(cultureNames, new CalendarFormatInfo.DayOfWeekStyle("Z", "@", true));
Expand All @@ -139,7 +134,7 @@ public void ResettingDayOfWeekStyleOfMultipleCultures()
{
var result = CalendarFormatInfo.FromCultureInfo(CultureInfo.GetCultureInfo(cultureName));
await Assert.That(result.ComponentOnePattern).IsEqualTo("d MMM");
await Assert.That(", result.ComponentTwoPattern).IsEqualTo("ddd);
await Assert.That(result.ComponentTwoPattern).IsEqualTo("ddd");
}
}
}
8 changes: 1 addition & 7 deletions tests/MaterialDesignThemes.Wpf.Tests/CheckBoxAssistTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;
namespace MaterialDesignThemes.Wpf.Tests;

public class CheckBoxAssistTests
{
Expand Down
24 changes: 9 additions & 15 deletions tests/MaterialDesignThemes.Wpf.Tests/ClockTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;
namespace MaterialDesignThemes.Wpf.Tests;

public class ClockTests
{
[StaFact(Timeout = 500)]
[Test, STAThreadExecutor]
public async Task CanGenerateHoursButtons()
{
var clock = new Clock();
Expand All @@ -21,7 +15,7 @@ public async Task CanGenerateHoursButtons()
await Assert.That(buttonContents.OrderBy(x => x)).IsEqualTo(expected.OrderBy(x => x));
}

[StaFact(Timeout = 500)]
[Test, STAThreadExecutor]
public async Task CanGenerateHoursButtonsWith24Hours()
{
var clock = new Clock { Is24Hours = true };
Expand All @@ -36,8 +30,8 @@ public async Task CanGenerateHoursButtonsWith24Hours()
await Assert.That(buttonContents.OrderBy(x => x)).IsEqualTo(expected.OrderBy(x => x));
}

[StaFact(Timeout = 500)]
public void CanGenerateMinuteButtons()
[Test, STAThreadExecutor]
public async Task CanGenerateMinuteButtons()
{
var clock = new Clock();
clock.ApplyDefaultStyle();
Expand All @@ -49,8 +43,8 @@ public void CanGenerateMinuteButtons()
await Assert.That(buttonContents.OrderBy(x => x)).IsEqualTo(expected.OrderBy(x => x));
}

[StaFact(Timeout = 500)]
public void CanGenerateSecondsButtons()
[Test, STAThreadExecutor]
public async Task CanGenerateSecondsButtons()
{
var clock = new Clock();
clock.ApplyDefaultStyle();
Expand All @@ -62,8 +56,8 @@ public void CanGenerateSecondsButtons()
await Assert.That(buttonContents.OrderBy(x => x)).IsEqualTo(expected.OrderBy(x => x));
}

[StaFact(Timeout = 500)]
public void TimeChangedEvent_WhenTimeChanges_EventIsRaised()
[Test, STAThreadExecutor]
public async Task TimeChangedEvent_WhenTimeChanges_EventIsRaised()
{
var clock = new Clock();
clock.ApplyDefaultStyle();
Expand Down
31 changes: 13 additions & 18 deletions tests/MaterialDesignThemes.Wpf.Tests/CustomColorThemeTests.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System.Windows.Media;

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;

public class CustomColorThemeTests
{
[StaTheory]
[Test, STAThreadExecutor]
[MethodDataSource(nameof(GetThemeValues))]
public async Task WhenValueIsMissingThemeIsNotSet(BaseTheme? baseTheme, Color? primaryColor, Color? secondaryColor)
{
Expand All @@ -22,20 +17,20 @@ public async Task WhenValueIsMissingThemeIsNotSet(BaseTheme? baseTheme, Color? p
bundledTheme.SecondaryColor = secondaryColor;

//Assert
await Assert.That(() => bundledTheme.GetTheme()).ThrowsExactly<InvalidOperationException>();
await Assert.That(bundledTheme.GetTheme).ThrowsExactly<InvalidOperationException>();
}

public static IEnumerable<object?[]> GetThemeValues()
public static IEnumerable<(BaseTheme?, Color?, Color?)> GetThemeValues()
{
yield return new object?[] { null, null, null };
yield return new object?[] { BaseTheme.Light, null, null };
yield return new object?[] { BaseTheme.Inherit, null, null };
yield return new object?[] { null, Colors.Blue, null };
yield return new object?[] { BaseTheme.Light, Colors.Blue, null };
yield return new object?[] { BaseTheme.Inherit, Colors.Blue, null };
yield return new object?[] { null, null, Colors.Blue };
yield return new object?[] { BaseTheme.Light, null, Colors.Blue };
yield return new object?[] { BaseTheme.Inherit, null, Colors.Blue };
yield return (null, null, null);
yield return (BaseTheme.Light, null, null);
yield return (BaseTheme.Inherit, null, null);
yield return (null, Colors.Blue, null);
yield return (BaseTheme.Light, Colors.Blue, null);
yield return (BaseTheme.Inherit, Colors.Blue, null);
yield return (null, null, Colors.Blue);
yield return (BaseTheme.Light, null, Colors.Blue);
yield return (BaseTheme.Inherit, null, Colors.Blue);
}

[Test, STAThreadExecutor]
Expand All @@ -57,6 +52,6 @@ public async Task WhenAllValuesAreSetThemeIsSet()
var lightTheme = new Theme();
lightTheme.SetLightTheme();
await Assert.That(theme.Foreground).IsEqualTo(lightTheme.Foreground);
Assert.NotEqual(default, theme.Foreground);
await Assert.That(theme.Foreground).IsNotDefault();
}
}
7 changes: 1 addition & 6 deletions tests/MaterialDesignThemes.Wpf.Tests/DataGridAssistTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;
namespace MaterialDesignThemes.Wpf.Tests;

public class DataGridAssistTests
{
Expand Down
5 changes: 0 additions & 5 deletions tests/MaterialDesignThemes.Wpf.Tests/DrawerHostTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System.ComponentModel;

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;

public class DrawerHostTests : IDisposable
Expand Down
2 changes: 0 additions & 2 deletions tests/MaterialDesignThemes.Wpf.Tests/EnumDataAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Reflection;
using Xunit.Sdk;
using Xunit.v3;

namespace MaterialDesignThemes.Wpf.Tests;

Expand Down
8 changes: 1 addition & 7 deletions tests/MaterialDesignThemes.Wpf.Tests/FlipperAssistTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;
namespace MaterialDesignThemes.Wpf.Tests;

public class FlipperAssistTests
{
Expand Down
5 changes: 0 additions & 5 deletions tests/MaterialDesignThemes.Wpf.Tests/LabelTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System.ComponentModel;

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;

public class LabelTests
Expand Down
7 changes: 2 additions & 5 deletions tests/MaterialDesignThemes.Wpf.Tests/MdixHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;

Expand All @@ -19,11 +16,11 @@ static MdixHelper()
public static async Task ApplyStyle<T>(this T control, object styleKey, bool applyTemplate = true) where T : FrameworkElement
{
var style = GetStyle(styleKey);
await Assert.That($"Could not find style with key '{styleKey}' for control type {typeof(T).FullName}").IsTrue();
await Assert.That(style).IsNotNull().Because($"Could not find style with key '{styleKey}' for control type {typeof(T).FullName}");
control.Style = style;
if (applyTemplate)
{
await Assert.That("Failed to apply template").IsTrue();
Assert.Fail("Failed to apply template");
}
}

Expand Down
8 changes: 2 additions & 6 deletions tests/MaterialDesignThemes.Wpf.Tests/PackIconTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System.ComponentModel;

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;

public class PackIconTests
Expand All @@ -16,7 +11,8 @@ public async Task EnumMembersMustNotDifferByOnlyCase()
var enumValues = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var enumMember in Enum.GetNames(typeof(PackIconKind)))
{
await Assert.That($"{enumMember} matches existing enum value and differs only by case").IsTrue();
await Assert.That(enumValues.Add(enumMember)).IsTrue()
.Because($"{enumMember} matches existing enum value and differs only by case");
}
}
}
5 changes: 0 additions & 5 deletions tests/MaterialDesignThemes.Wpf.Tests/PopupBoxTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System.ComponentModel;

using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests;

public class PopupBoxTests
Expand Down
Loading