feat(lists): selectable list/folder colors with accent-aware swatches and custom picker
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Avalonia.Media;
|
||||
using ClaudeDo.Ui.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace ClaudeDo.Ui.Tests;
|
||||
|
||||
public class ColorBrushConverterTests
|
||||
{
|
||||
private static readonly SolidColorBrush Swatch3 = new(Colors.Red);
|
||||
private static readonly SolidColorBrush Fallback = new(Colors.Gray);
|
||||
|
||||
private static object? Lookup(string key) => key switch
|
||||
{
|
||||
"Swatch3Brush" => Swatch3,
|
||||
"FallbackBrush" => Fallback,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void SwatchKey_ResolvesToTheAppResource()
|
||||
=> Assert.Same(Swatch3, ColorBrushConverter.Resolve("Swatch3", "FallbackBrush", Lookup));
|
||||
|
||||
[Fact]
|
||||
public void Hex_BecomesASolidBrush()
|
||||
{
|
||||
var brush = Assert.IsType<SolidColorBrush>(ColorBrushConverter.Resolve("#112233", "FallbackBrush", Lookup));
|
||||
Assert.Equal(Color.Parse("#112233"), brush.Color);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData("Swatch99")]
|
||||
[InlineData("#nothex")]
|
||||
public void NullEmptyOrInvalid_FallsBackToTheParameter(string? value)
|
||||
=> Assert.Same(Fallback, ColorBrushConverter.Resolve(value, "FallbackBrush", Lookup));
|
||||
|
||||
[Fact]
|
||||
public void NoFallbackParameter_ReturnsNull()
|
||||
=> Assert.Null(ColorBrushConverter.Resolve(null, null, Lookup));
|
||||
}
|
||||
Reference in New Issue
Block a user