Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
ede38d4
Cleanup of launchSettings and Cards Page in Demo
Oct 24, 2024
8c8644a
Revert "Cleanup of launchSettings and Cards Page in Demo"
Oct 24, 2024
550c20d
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Oct 29, 2024
649b234
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Nov 4, 2024
83ab505
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Nov 19, 2024
75b12a6
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Nov 29, 2024
ec4ab7e
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Dec 12, 2024
693f32e
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Dec 20, 2024
ffc320a
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Jan 2, 2025
d216821
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Jan 3, 2025
5ea61a4
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Jan 8, 2025
202c919
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Jan 27, 2025
1eb432e
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Jan 31, 2025
622c328
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Feb 12, 2025
737a145
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Feb 17, 2025
27bbd55
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Feb 28, 2025
0751054
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Mar 11, 2025
7d9cf1b
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Mar 12, 2025
129653d
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Mar 14, 2025
4858124
Merge branch 'master' of https://github.com/corvinsz/MaterialDesignIn…
Mar 31, 2025
8228167
-added "isFullscreenDialog" Parameter to all Dialog.Show methods
Mar 31, 2025
5e386eb
before showing the Dialog remove the Dialogs Margin and CornerRadius …
corvinsz Mar 31, 2025
4466075
added summary description for "isFullscreenDialog"
corvinsz Mar 31, 2025
34f7767
applied newer "syntactic sugar" features
corvinsz Mar 31, 2025
485a4ca
resize and reposition the PopupEx if the Window is resized or reposit…
Apr 1, 2025
7e8d9fc
added PART_CloseButton to the Template of the DialogHost
Apr 1, 2025
e5d37f3
-added DialogOptions class
Apr 1, 2025
f1d4c2a
-added demo page for DialogOptions
corvinsz Apr 1, 2025
d0b71cb
demo cleanup
corvinsz Apr 2, 2025
f36b86a
save size of Popup before setting it to fullscreen so the height and …
corvinsz Apr 2, 2025
e43653e
-removed unused variables and summaries
corvinsz Apr 2, 2025
5ff9626
added BlurBackground to the DialogOptions and showcase it the demo
corvinsz Apr 10, 2025
e98f550
Mark the old Show methods as obsolete
corvinsz Apr 10, 2025
2444022
fix to restore the BlurRadius correctly
corvinsz Apr 29, 2025
affc82a
-if no DialogOptions are supplied, fall back to Defaults
corvinsz Apr 29, 2025
1e856d0
Lift ContentControl from child of Ripple, to sibling of Ripple (#3843)
nicolaihenriksen May 9, 2025
1ab7331
use powershell script to convert old brush names to new ones (#3846)
corvinsz May 9, 2025
f5a504d
UpDownBase: Fix event subscription mismatch (#3844)
nicolaihenriksen May 9, 2025
3b30b20
Fix AutoSuggestBox not setting SelectedItem (#3847)
corvinsz May 9, 2025
35167df
added AP to control the cursor when hovering over a ListBoxItem and m…
corvinsz May 16, 2025
5f75c3b
Fix for 3851 - Dark mode not working anymore (#3852)
JorisCleVR May 30, 2025
c506371
Chip: Added TemplateBinding Padding (#3850)
JorisCleVR May 30, 2025
db64576
Set MaterialDesignPopupBox/PART_Toggle.VerticalAlignment to Stretch (…
greuelpirat May 30, 2025
e7bc4d3
Fix namespace for DesignInstances in MaterialDesignDemo.Shared.Domain…
greuelpirat May 30, 2025
c2c8793
Use CultureInfo.CurrentCulture for string conversions of Value (#3860)
nicolaihenriksen Jun 6, 2025
7ddc81b
#3853: RelativeSource FindAncestor binding errors (#3862)
JorisCleVR Jun 6, 2025
6cef2f5
Forward HintAssist.HintPaddingBrush into nested TextBox of UpDown (#3…
nicolaihenriksen Jun 6, 2025
0ed85d0
Modify DecimalUpDown basic test to ensure culture is respected in str…
nicolaihenriksen Jun 8, 2025
f0f5fdc
Fixed PopUpBox VerticalContentAlignment (#3864)
JorisCleVR Jun 8, 2025
442f311
Used x:Reference in Button and ProgressBar ControlTemplates (#3868)
JorisCleVR Jun 13, 2025
182b60a
Chip: Fixed without icon padding (#3869)
JorisCleVR Jun 13, 2025
556b412
ToggleButton uses EllipseClipConverter (#3867)
JorisCleVR Jun 13, 2025
cf1afbc
Remove .NET 6 as EOL (#3859)
L1nstead Jun 13, 2025
66b836b
TextBoxLineCountBehavior: Fixed NullReferenceException when used with…
JorisCleVR Jun 13, 2025
4733a54
Evaluate TextBox.LineCount only once in UpdateAttachedProperties (#3874)
greuelpirat Jun 18, 2025
122a534
added ToolTip demo page with a RichToolTip example. Applied new synta…
corvinsz Jun 19, 2025
bbdee06
fix when the TreeListView expands too much content, scrolling to the …
MohammadHadi2031 Jun 26, 2025
f31fe78
Updating tests to use TUnit and MTP (#3838)
Keboo Jun 27, 2025
b110061
Fix Enhance Mouseover Visuals for TabControl (#3803)
corvinsz Jun 27, 2025
fad77d5
Exposes BindableIsItemsHost attached property. (#3878)
Keboo Jun 27, 2025
22d4651
Revert "Cleanup of launchSettings and Cards Page in Demo"
Oct 24, 2024
8d41d5e
-added "isFullscreenDialog" Parameter to all Dialog.Show methods
Mar 31, 2025
1bd4fe9
before showing the Dialog remove the Dialogs Margin and CornerRadius …
corvinsz Mar 31, 2025
169d77c
added summary description for "isFullscreenDialog"
corvinsz Mar 31, 2025
3ad8685
applied newer "syntactic sugar" features
corvinsz Mar 31, 2025
39f3dee
resize and reposition the PopupEx if the Window is resized or reposit…
Apr 1, 2025
e2a934b
added PART_CloseButton to the Template of the DialogHost
Apr 1, 2025
b4ea591
-added DialogOptions class
Apr 1, 2025
e24c4b5
-added demo page for DialogOptions
corvinsz Apr 1, 2025
a8ca75d
demo cleanup
corvinsz Apr 2, 2025
613bbd0
save size of Popup before setting it to fullscreen so the height and …
corvinsz Apr 2, 2025
b98c47d
-removed unused variables and summaries
corvinsz Apr 2, 2025
570e85f
added BlurBackground to the DialogOptions and showcase it the demo
corvinsz Apr 10, 2025
a3ebda1
Mark the old Show methods as obsolete
corvinsz Apr 10, 2025
9b5eb8a
fix to restore the BlurRadius correctly
corvinsz Apr 29, 2025
4b2a1b0
-if no DialogOptions are supplied, fall back to Defaults
corvinsz Apr 29, 2025
4104cc2
Merge branch 'feat/FullscreenDialog' of https://github.com/corvinsz/M…
corvinsz Jul 1, 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
Updating tests to use TUnit and MTP (#3838)
* Updating to xUnit v3 1.x

* Adding MTP

https://devblogs.microsoft.com/dotnet/mtp-adoption-frameworks/

* Starting conversion to TUnit

* Tests all compile

* Adds cancellation tokens to async delays

Ensures that asynchronous delay calls use cancellation tokens to allow for tests to be cancelled correctly.

* WIP

* Refactors test suite and updates dependencies

Updates the test suite to use TUnit for improved test clarity and maintainability.
Removes unused xunit packages and addresses nullable warnings in RatingBar converters.
Also includes changes to CustomColorTheme, DataGridAssist, DialogHost, DrawerHost, FlipperAssist, Internal/TreeListViewItemsCollection, Label, MaterialDesignThemes.Wpf.Tests.csproj, MdixHelper, PackIcon, PopupBox, RatingBar, SnackbarMessageQueue, TextBlock, TextBox, Theme and Transitioner tests.

* Updates test framework and fixes assertions

Updates test framework from Fact to Test.

Updates tests to use Assert.That for improved readability and consistency.

* Reverting stupid

* Save point

* Assert.True

* Updates tests to be async

Updates tests to be async to prevent possible deadlocks and improve reliability.

* Removes TUnit dependencies from tests

Removes the TUnit library and associated code from test projects, modernizing testing using the default testing framework.

* Tests are now compiling

* Updates test framework for DecimalUpDown

Converts the DecimalUpDown test to use the `Arguments` attribute and updates assertions to improve reliability and clarity.

* Fixing member data sources

Updates TimePicker unit tests to use MethodDataSource with Func to prevent test data from being eagerly evaluated, resolving issues with the test framework.

* Refactors code for brevity and adds tests

Updates collection initialization to use more concise syntax.
Adds tests for the ButtonProgressAssist, CheckBoxAssist, ColorPicker, and DataGridAssist classes.
Adds a new test executor and removes redundant STAThreadExecutor attributes.
Adds NotInParallel attribute to CalendarFormatInfoTests and DialogHostTests.
Refactors the PreviewIndicatorTransformXConverter and PreviewIndicatorTransformYConverter.

* Updates screenshot artifact path

Updates the path for screenshot artifacts to target the .NET 9 framework.

* Fixes artifact upload path

Corrects the artifact upload path in the build workflow.

* Updates coordinate assertion method

Uses IsCloseTo method for asserting coordinate proximity in UI tests for ComboBoxes, DatePickers, PasswordBoxes, and TextBoxes.
This improves the accuracy and reliability of the tests by checking if the coordinates are within a specified tolerance range.

* Updates NuGet package versions

Updates several NuGet package versions, including Microsoft.NET.Test.Sdk, TUnit, and XAMLTest.

Fixes a potential issue in a test case by using CancellationToken.None instead of TestContext.Current!.CancellationToken

* Fixes UI test failures

Corrects failing UI tests by adjusting assertions and adding exception handling.

The fixes improve the stability and reliability of the UI test suite.

* Fixes combo box test assertion

Updates test assertion to expect a null text value when a combo box is uninitialized.
This corrects the expected behavior of the test.

* Updates artifact path for .NET 9

Updates the artifact upload path in the build workflow to correctly target the .NET 9 framework.
This resolves an issue where artifacts were not being correctly uploaded due to an incorrect target framework name.

* Adds success recorder in auto suggest box tests

* Skips flaky GetDialogSession test

* Skips failing saturation drag test

Skips a ColorPicker test that was failing before the move to Machine.Time.Past due to timing issues in the while loop.

* Ensures DialogHost is properly unloaded

Introduces a `ControlHost` class to ensure the `DialogHost` is properly unloaded when the test is complete.
This prevents orphaned `DialogHost` instances from interfering with subsequent tests.
  • Loading branch information
Keboo authored Jun 27, 2025
commit f31fe7812312c4829fccc23844f6c3cfd2c4a0c3
2 changes: 1 addition & 1 deletion .github/workflows/build_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions Directory.packages.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project>
<ItemGroup>
<PackageVersion Include="BluwolfIcons" Version="1.0.1" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageVersion Include="Dragablz" Version="0.0.3.234" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="Humanizer" Version="2.14.1" />
<PackageVersion Include="MahApps.Metro" Version="2.4.10" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
Expand All @@ -14,7 +14,7 @@
<PackageVersion Include="Microsoft.Composition" Version="1.0.31" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.NETCore.Platforms" Version="7.0.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Microsoft.Toolkit.MVVM" Version="7.1.2" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
Expand All @@ -24,11 +24,10 @@
<PackageVersion Include="ShowMeTheXAML.MSBuild" Version="2.0.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageVersion Include="TUnit" Version="0.25.21" />
<PackageVersion Include="VirtualizingWrapPanel" Version="1.5.8" />
<PackageVersion Include="XAMLTest" Version="1.3.0-ci602" />
<PackageVersion Include="xunit" Version="2.6.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageVersion Include="Xunit.StaFact" Version="1.1.11" />
<PackageVersion Include="XAMLTest" Version="1.3.0-ci616" />
</ItemGroup>
</Project>
18 changes: 9 additions & 9 deletions src/MaterialDesignColors.Wpf/SwatchesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace MaterialDesignColors;
/// </summary>
public class SwatchesProvider
{
private static readonly object _syncLock = new();
/// <summary>
/// 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.
Expand Down Expand Up @@ -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<Swatch>)Array.Empty<Swatch>();
#else
(IEnumerable<Swatch>)new Swatch[0];
#endif
.ToList() ?? [];
}

/// <summary>
Expand Down Expand Up @@ -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));
}
}
}
4 changes: 2 additions & 2 deletions src/MaterialDesignThemes.Wpf/DialogHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class DialogHost : ContentControl
/// </summary>
public static readonly RoutedCommand CloseDialogCommand = new();

private static readonly HashSet<WeakReference<DialogHost>> LoadedInstances = new();
private static readonly HashSet<WeakReference<DialogHost>> LoadedInstances = [];

private DialogOpenedEventHandler? _asyncShowOpenedEventHandler;
private DialogClosingEventHandler? _asyncShowClosingEventHandler;
Expand Down Expand Up @@ -221,7 +221,7 @@ private static DialogHost GetInstance(object? dialogIdentifier)
if (LoadedInstances.Count == 0)
throw new InvalidOperationException("No loaded DialogHost instances.");

List<DialogHost> targets = new();
List<DialogHost> targets = [];
foreach (var instance in LoadedInstances.ToList())
{
if (instance.TryGetTarget(out DialogHost? dialogInstance))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace MaterialDesignThemes.Wpf.Internal;

public class TreeListViewItemsCollection : ObservableCollection<object?>
{
private List<int> ItemLevels { get; } = new();
private List<bool> ItemIsExpanded { get; } = new();
private List<int> ItemLevels { get; } = [];
private List<bool> ItemIsExpanded { get; } = [];

public TreeListViewItemsCollection(object? wrappedSource)
{
Expand Down
38 changes: 19 additions & 19 deletions src/MaterialDesignThemes.Wpf/RatingBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ internal class TextBlockForegroundConverter : IMultiValueConverter

public static TextBlockForegroundConverter Instance { get; } = new();

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object?[]? values, Type targetType, object? parameter, CultureInfo culture)
{
if (values?.Length == 5
&& values[0] is SolidColorBrush brush
Expand Down Expand Up @@ -411,28 +411,28 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
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()
{
new GradientStop {Color = semiTransparent, Offset = offset},
new GradientStop {Color = originalColor, Offset = offset},
};
}
return new()
{
return
[
new GradientStop {Color = semiTransparent, Offset = offset},
new GradientStop {Color = originalColor, Offset = offset},
new GradientStop {Color = semiTransparent, Offset = offset}
};
];
}
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)
return Brushes.Transparent;
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
public object?[]? ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotImplementedException();
}

internal class PreviewIndicatorTransformXConverter : IMultiValueConverter
Expand All @@ -441,9 +441,9 @@ internal class PreviewIndicatorTransformXConverter : IMultiValueConverter

internal static double Margin => 2.0;

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object?[]? values, Type targetType, object? parameter, CultureInfo culture)
{
if (values.Length >= 7
if (values?.Length >= 7
&& values[0] is double ratingBarButtonActualWidth
&& values[1] is double previewValueActualWidth
&& values[2] is Orientation ratingBarOrientation
Expand Down Expand Up @@ -482,7 +482,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
return 1.0;
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
public object?[]? ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotImplementedException();
}

internal class PreviewIndicatorTransformYConverter : IMultiValueConverter
Expand All @@ -491,9 +491,9 @@ internal class PreviewIndicatorTransformYConverter : IMultiValueConverter

internal static double Margin => 2.0;

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
public object? Convert(object?[]? values, Type targetType, object? parameter, CultureInfo culture)
{
if (values.Length >= 7
if (values?.Length >= 7
&& values[0] is double ratingBarButtonActualHeight
&& values[1] is double previewValueActualHeight
&& values[2] is Orientation ratingBarOrientation
Expand Down Expand Up @@ -531,6 +531,6 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
return 1.0;
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
public object?[]? ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by mdresgen.
// This code was generated by MaterialDesignToolkit.ResourceGeneration.
// </auto-generated>
//------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/MaterialDesignThemes.Wpf/Theme.g.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by mdresgen.
// This code was generated by MaterialDesignToolkit.ResourceGeneration.
// </auto-generated>
//------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/MaterialDesignThemes.Wpf/ThemeExtensions.g.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by mdresgen.
// This code was generated by MaterialDesignToolkit.ResourceGeneration.
// </auto-generated>
//------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void WriteBrush(Brush brush, string name)
{{indent}}{{indent}}{
{{indent}}{{indent}}{{indent}}IVisualElement<TextBlock> textBlock = await panel.GetElement<TextBlock>("[Text=\"{{name}}\"]");
{{indent}}{{indent}}{{indent}}Color? textBlockBackground = await textBlock.GetBackgroundColor();
{{indent}}{{indent}}{{indent}}Assert.Equal(await GetResourceColor("{{brush.Name}}"), textBlockBackground);
{{indent}}{{indent}}{{indent}}await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("{{brush.Name}}"));
{{indent}}{{indent}}}
""");
}
Expand Down
9 changes: 4 additions & 5 deletions tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
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);

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<TargetFrameworks>net472;net8.0-windows</TargetFrameworks>
<AssemblyTitle>MaterialDesignColors.Wpf.Tests</AssemblyTitle>
<Product>MaterialDesignColors.Wpf.Tests</Product>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<OutputType>Exe</OutputType>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net472'">
<Reference Include="PresentationCore" />
Expand All @@ -25,9 +28,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="Shouldly" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="System.Net.Http" />
<PackageReference Include="System.Private.Uri" />
<PackageReference Include="System.Text.RegularExpressions" />
<PackageReference Include="TUnit" />
</ItemGroup>
</Project>
41 changes: 19 additions & 22 deletions tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs
Original file line number Diff line number Diff line change
@@ -1,65 +1,62 @@
using Shouldly;
using Xunit;

namespace MaterialDesignColors.Wpf.Fixture;
namespace MaterialDesignColors.Wpf.Tests;

public class ResourceProviderFixture
{
[Fact]
public void ExcludesBlack()
[Test]
public async Task ExcludesBlack()
{
SwatchesProvider swatchesProvider = new ();

bool containsBlack = swatchesProvider.Swatches.Any(
swatch => string.Compare(swatch.Name, "Black", StringComparison.InvariantCultureIgnoreCase) == 0);

containsBlack.ShouldBe(false);
await Assert.That(containsBlack).IsFalse();
}

[Fact]
public void IncludesGrey()
[Test]
public async Task IncludesGrey()
{
SwatchesProvider swatchesProvider = new ();

bool containsBlack = swatchesProvider.Swatches.Any(
swatch => string.Compare(swatch.Name, "Grey", StringComparison.InvariantCultureIgnoreCase) == 0);

containsBlack.ShouldBe(true);
await Assert.That(containsBlack).IsTrue();
}

[Fact]
public void BrownHasNoSecondary()
[Test]
public async Task BrownHasNoSecondary()
{
SwatchesProvider swatchesProvider = new ();

var brownSwatch = swatchesProvider.Swatches.Single(
swatch => swatch.Name == "brown");

brownSwatch.SecondaryHues.ShouldNotBeNull();
brownSwatch.SecondaryHues.Count.ShouldBe(0);
await Assert.That(brownSwatch.SecondaryHues).IsNotNull();
await Assert.That(brownSwatch.SecondaryHues.Count).IsEqualTo(0);
}

[Fact]
public void BrownHasPrimaries()
[Test]
public async Task BrownHasPrimaries()
{
SwatchesProvider swatchesProvider = new ();

var brownSwatch = swatchesProvider.Swatches.Single(
swatch => swatch.Name == "brown");

brownSwatch.PrimaryHues.ShouldNotBeNull();
brownSwatch.PrimaryHues.Count.ShouldBe(10);
await Assert.That(brownSwatch.PrimaryHues).IsNotNull();
await Assert.That(brownSwatch.PrimaryHues.Count).IsEqualTo(10);
}

[Fact]
public void IndigoHasSecondaries()
[Test]
public async Task IndigoHasSecondaries()
{
SwatchesProvider swatchesProvider = new ();

var brownSwatch = swatchesProvider.Swatches.Single(
swatch => swatch.Name == "indigo");

brownSwatch.SecondaryHues.ShouldNotBeNull();
brownSwatch.SecondaryHues.Count.ShouldBe(4);
await Assert.That(brownSwatch.SecondaryHues).IsNotNull();
await Assert.That(brownSwatch.SecondaryHues.Count).IsEqualTo(4);
}
}
Loading
Loading