mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 16:46:08 +02:00
- Added new attributes for chat colors including rail, date rules, and unread markers. - Enhanced ChatLine class to support colored segments for continuation lines and horizontal separator rules. - Introduced a WelcomeBanner class to display a splash screen when no channel is selected. - Implemented NickColorHelper for deterministic per-nick colors, ensuring consistent user color representation. - Updated ChannelListSource to highlight channels with unread messages and mentions. - Improved MainWindow to include a spinner for transitional connection states and display activity in the status bar. - Added unit tests for NickColorHelper to ensure stable and predictable color indexing.
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using EchoHub.Client.UI.Helpers;
|
|
using Xunit;
|
|
|
|
namespace EchoHub.Tests;
|
|
|
|
/// <summary>
|
|
/// Tests for the deterministic nick→palette-index hash.
|
|
/// Note: GetAttribute (Terminal.Gui Attribute) is excluded — Terminal.Gui's module
|
|
/// initializer requires a display driver unavailable in CI.
|
|
/// </summary>
|
|
public class NickColorHelperTests
|
|
{
|
|
[Fact]
|
|
public void GetPaletteIndex_SameNick_IsStable()
|
|
{
|
|
var first = NickColorHelper.GetPaletteIndex("alice", 12);
|
|
var second = NickColorHelper.GetPaletteIndex("alice", 12);
|
|
Assert.Equal(first, second);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetPaletteIndex_IsCaseInsensitive()
|
|
{
|
|
Assert.Equal(
|
|
NickColorHelper.GetPaletteIndex("Alice", 12),
|
|
NickColorHelper.GetPaletteIndex("aLICE", 12));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("alice")]
|
|
[InlineData("bob")]
|
|
[InlineData("charlie_long_nickname")]
|
|
[InlineData("")]
|
|
[InlineData("émile")]
|
|
public void GetPaletteIndex_AlwaysWithinRange(string nick)
|
|
{
|
|
var index = NickColorHelper.GetPaletteIndex(nick, 12);
|
|
Assert.InRange(index, 0, 11);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetPaletteIndex_DistributesAcrossPalette()
|
|
{
|
|
// Not a strict uniformity test — just that the hash isn't degenerate
|
|
var nicks = new[] { "alice", "bob", "carol", "dave", "erin", "frank", "grace", "heidi" };
|
|
var distinct = nicks.Select(n => NickColorHelper.GetPaletteIndex(n, 12)).Distinct().Count();
|
|
Assert.True(distinct >= 3, $"Expected at least 3 distinct palette slots, got {distinct}");
|
|
}
|
|
|
|
[Fact]
|
|
public void GetPaletteIndex_NonPositivePaletteSize_ReturnsZero()
|
|
{
|
|
Assert.Equal(0, NickColorHelper.GetPaletteIndex("alice", 0));
|
|
}
|
|
}
|