using PkmnLib.Static.Utils;

namespace PkmnLib.Tests.Static;

public class StringKeyTests
{
    public static IEnumerable<Func<(string, string, bool)>> StringKeyEqualityTestCases()
    {
        yield return () => ("test", "test", true);
        yield return () => ("test", "test2", false);
        yield return () => ("test2", "test2", true);
        yield return () => ("Test", "test", true);
        yield return () => ("TeSt", "tesT", true);
        yield return () => ("TeSt", "tesv", false);
    }

    [Test, MethodDataSource(nameof(StringKeyEqualityTestCases))]
    public async Task StringKeyEqualityTest(string k1, string k2, bool expected)
    {
        var sk1 = new StringKey(k1);
        var sk2 = new StringKey(k2);
        await Assert.That(sk1 == sk2).IsEqualTo(expected);
    }

    [Test, MethodDataSource(nameof(StringKeyEqualityTestCases))]
    public async Task StringKeyInequalityTest(string k1, string k2, bool expected)
    {
        var sk1 = new StringKey(k1);
        var sk2 = new StringKey(k2);
        await Assert.That(sk1 != sk2).IsNotEqualTo(expected);
    }

    [Test, MethodDataSource(nameof(StringKeyEqualityTestCases))]
    public async Task HashCodeEqualityTest(string k1, string k2, bool expected)
    {
        var sk1 = new StringKey(k1);
        var sk2 = new StringKey(k2);
        await Assert.That(sk1.GetHashCode() == sk2.GetHashCode()).IsEqualTo(expected);
    }

    [Test, MethodDataSource(nameof(StringKeyEqualityTestCases))]
    public async Task HashSetEqualityTest(string k1, string k2, bool expected)
    {
        var sk1 = new StringKey(k1);
        var sk2 = new StringKey(k2);
        var hs = new HashSet<StringKey> { sk1 };
        await Assert.That(hs.Contains(sk2)).IsEqualTo(expected);
    }
}