using System; using System.Linq; using Xunit; using ytLive.Models; namespace ytLive.Tests; /// TASK 60 — the creator (2026-10-21): *"under Live->Layers->webcam-> /// Properties->border color: in the drop down box, the #hex values are good, but add a /// corresponding color name/label next to the value."* /// /// One test: the palette is the single source of truth for the drop-down (the /// picker builds its menu from it and carries no list of its own), every entry has a /// valid hex and a name, the names are unique, the colours the picker used to offer are /// all still offered, and the lookup answers for a hex the creator typed. public class BorderColorPaletteTests { [Fact] public void The_border_palette_names_every_colour_the_picker_offers() { // 1. Every entry is a valid hex with a name, and no hex or name repeats. Assert.NotEmpty(BorderColorPalette.All); foreach (var colour in BorderColorPalette.All) { Assert.Matches("^#[0-9a-fA-F]{6}$", colour.Hex); Assert.False(string.IsNullOrWhiteSpace(colour.Name), $"{colour.Hex} has no name"); } Assert.Equal(BorderColorPalette.All.Count, BorderColorPalette.All.Select(c => c.Hex).Distinct(StringComparer.OrdinalIgnoreCase).Count()); Assert.Equal(BorderColorPalette.All.Count, BorderColorPalette.All.Select(c => c.Name).Distinct(StringComparer.OrdinalIgnoreCase).Count()); // 2. The colours the picker used to offer are all still offered. string[] legacy = ["#FFFFFF", "#000000", "#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#FF8800", "#8800FF", "#e94560", "#22c55e", "#3b82f6", "#f59e0b"]; foreach (var hex in legacy) Assert.Contains(BorderColorPalette.All, c => c.Hex == hex); // 3. The lookup answers for a hex in any case, and keeps an unknown hex as-is. Assert.Equal("Crimson", BorderColorPalette.NameOf("#e94560")); Assert.Equal("Crimson", BorderColorPalette.NameOf("#E94560")); Assert.Equal("White", BorderColorPalette.NameOf(" #ffffff ")); Assert.Equal("#123456", BorderColorPalette.NameOf("#123456")); // 4. The picker builds its menu from the catalogue — there is no second list. var source = SourceAssert.Text("Controls", "LeftPanel.xaml.cs"); Assert.True(source.Contains("BorderColorPalette"), "the border picker does not build its menu from the palette"); Assert.False(source.Contains("\"#FFFFFF\""), "the border picker still carries its own list of colours"); } }