feat(bot): Case insensitive proxy tags matching (#490)
This commit is contained in:
@@ -9,9 +9,10 @@ namespace PluralKit.Tests;
|
||||
public class ProxyTagParserTests
|
||||
{
|
||||
internal static ProxyMatch AssertMatch(IEnumerable<ProxyMember> members, string input, string? name = null,
|
||||
string? prefix = null, string? suffix = null, string? content = null)
|
||||
string? prefix = null, string? suffix = null, string? content = null,
|
||||
bool caseSensitive = true)
|
||||
{
|
||||
Assert.True(new ProxyTagParser().TryMatch(members, input, out var result));
|
||||
Assert.True(new ProxyTagParser().TryMatch(members, input, caseSensitive, out var result));
|
||||
if (name != null) Assert.Equal(name, result.Member.Name);
|
||||
if (prefix != null) Assert.Equal(prefix, result.ProxyTags?.Prefix);
|
||||
if (suffix != null) Assert.Equal(suffix, result.ProxyTags?.Suffix);
|
||||
@@ -19,9 +20,9 @@ public class ProxyTagParserTests
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static void AssertNoMatch(IEnumerable<ProxyMember> members, string? input)
|
||||
internal static void AssertNoMatch(IEnumerable<ProxyMember> members, string? input, bool caseSensitive = true)
|
||||
{
|
||||
Assert.False(new ProxyTagParser().TryMatch(members, input, out _));
|
||||
Assert.False(new ProxyTagParser().TryMatch(members, input, caseSensitive, out _));
|
||||
}
|
||||
|
||||
public class Basics
|
||||
@@ -46,6 +47,16 @@ public class ProxyTagParserTests
|
||||
public void StringWithTagsMatch(string input) =>
|
||||
AssertMatch(members, input);
|
||||
|
||||
[Theory]
|
||||
[InlineData("a:tag with lowercase prefix")]
|
||||
public void StringWithLowercaseUsingDefaultConfigMatchesNothing(string input) =>
|
||||
AssertNoMatch(members, input);
|
||||
|
||||
[Theory]
|
||||
[InlineData("a:tag with lowercase prefix")]
|
||||
public void StringWithLowercaseUsingCaseInsensitiveConfigMatches(string input) =>
|
||||
AssertMatch(members, input, caseSensitive: false);
|
||||
|
||||
[Theory]
|
||||
[InlineData("[john's tags]", "John")]
|
||||
[InlineData("{bob's tags}", "Bob")]
|
||||
|
||||
Reference in New Issue
Block a user