Files
GmRelayBot/tests/GmRelay.Bot.Tests/Domain/GameSystemTests.cs
T

66 lines
2.0 KiB
C#

using GmRelay.Shared.Domain;
namespace GmRelay.Bot.Tests.Domain;
public sealed class GameSystemTests
{
[Theory]
[InlineData("Dnd5e", GameSystem.Dnd5e)]
[InlineData("D&D", GameSystem.Dnd5e)]
[InlineData("dnd5e", GameSystem.Dnd5e)]
[InlineData(" dnd5e ", GameSystem.Dnd5e)]
[InlineData("D&D 5e", GameSystem.Dnd5e)]
[InlineData("pathfinder", GameSystem.Pathfinder2e)]
[InlineData("call of cthulhu", GameSystem.CallOfCthulhu7e)]
[InlineData("shadow", GameSystem.Shadowdark)]
[InlineData("dark", GameSystem.Shadowdark)]
[InlineData("unknown xyz", GameSystem.Other)]
public void TryParseFuzzy_ShouldMapInputToExpectedSystem(string input, GameSystem expected)
{
var result = GameSystemExtensions.TryParseFuzzy(input);
Assert.Equal(expected, result);
}
[Theory]
[InlineData("днд")]
[InlineData("колова")]
public void TryParseFuzzy_ShouldReturnOtherForUnmatchedCyrillicInput(string input)
{
var result = GameSystemExtensions.TryParseFuzzy(input);
Assert.Equal(GameSystem.Other, result);
}
[Fact]
public void TryParseFuzzy_ShouldReturnNullForNullInput()
{
var result = GameSystemExtensions.TryParseFuzzy(null!);
Assert.Null(result);
}
[Theory]
[InlineData("")]
[InlineData(" ")]
public void TryParseFuzzy_ShouldReturnNullForEmptyOrWhitespaceInput(string input)
{
var result = GameSystemExtensions.TryParseFuzzy(input);
Assert.Null(result);
}
[Theory]
[InlineData(GameSystem.Dnd5e, "D&D 5e")]
[InlineData(GameSystem.Other, "Другое")]
[InlineData(GameSystem.Pathfinder2e, "Pathfinder 2e")]
[InlineData(GameSystem.Shadowdark, "Shadowdark")]
[InlineData((GameSystem)999, "Другое")]
public void ToDisplayName_ShouldReturnExpectedName(GameSystem system, string expected)
{
var result = system.ToDisplayName();
Assert.Equal(expected, result);
}
}