41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using WxAgent.Core;
|
|
using Xunit;
|
|
|
|
namespace WxAgent.Core.Tests;
|
|
|
|
public sealed class WechatMentionOptionSelectionTests
|
|
{
|
|
[Fact]
|
|
public void SelectsOnlyAUniqueVisibleOptionForAUniqueDatabaseDisplayName()
|
|
{
|
|
string?[] members = ["Alice", "Bob"];
|
|
(string? Name, bool IsOffscreen, bool HasBounds)[] options =
|
|
[
|
|
("Alice", false, true),
|
|
("Bob", false, true)
|
|
];
|
|
|
|
Assert.Equal(0, WechatMentionOptionSelection.FindUniqueVisibleOptionIndex(members, options, "Alice"));
|
|
}
|
|
|
|
[Fact]
|
|
public void RejectsDatabaseDuplicatesEvenWhenOnlyOneCandidateIsVisible()
|
|
{
|
|
string?[] members = ["Alice", "Alice"];
|
|
(string? Name, bool IsOffscreen, bool HasBounds)[] options = [("Alice", false, true)];
|
|
|
|
Assert.Equal(-1, WechatMentionOptionSelection.FindUniqueVisibleOptionIndex(members, options, "Alice"));
|
|
}
|
|
|
|
[Fact]
|
|
public void RejectsOffscreenOrDuplicateUiCandidates()
|
|
{
|
|
string?[] members = ["Alice"];
|
|
(string? Name, bool IsOffscreen, bool HasBounds)[] offscreen = [("Alice", true, false)];
|
|
(string? Name, bool IsOffscreen, bool HasBounds)[] duplicate = [("Alice", false, true), ("Alice", true, false)];
|
|
|
|
Assert.Equal(-1, WechatMentionOptionSelection.FindUniqueVisibleOptionIndex(members, offscreen, "Alice"));
|
|
Assert.Equal(-1, WechatMentionOptionSelection.FindUniqueVisibleOptionIndex(members, duplicate, "Alice"));
|
|
}
|
|
}
|