// ---------------------------------------------------------------------------
// BT.Framework.Tests
// EnumToIntTests.cs — EnumToInt 박싱-프리 변환 단위 테스트
// ---------------------------------------------------------------------------
using NUnit.Framework;
using BurningTimes.Core.Util;

namespace BurningTimes.Tests.Core.Util
{
    public class EnumToIntTests
    {
        private enum Sample { A = 0, B = 1, C = 42, Neg = -5 }

        [Test]
        public void Convert_ReturnsUnderlyingIntValue()
        {
            Assert.That(EnumToInt.Convert(Sample.A), Is.EqualTo(0));
            Assert.That(EnumToInt.Convert(Sample.B), Is.EqualTo(1));
            Assert.That(EnumToInt.Convert(Sample.C), Is.EqualTo(42));
            Assert.That(EnumToInt.Convert(Sample.Neg), Is.EqualTo(-5));
        }

        [Test]
        public void FromInt_ReturnsMatchingEnum()
        {
            Assert.That(EnumToInt.FromInt<Sample>(42), Is.EqualTo(Sample.C));
            Assert.That(EnumToInt.FromInt<Sample>(-5), Is.EqualTo(Sample.Neg));
        }

        [Test]
        public void Equals_ComparesEnumValuesWithoutBoxing()
        {
            Assert.IsTrue(EnumToInt.Equals(Sample.C, Sample.C));
            Assert.IsFalse(EnumToInt.Equals(Sample.A, Sample.B));
        }

        [Test]
        public void RoundTrip_PreservesValue()
        {
            Sample original = Sample.C;
            int id = EnumToInt.Convert(original);
            Sample restored = EnumToInt.FromInt<Sample>(id);
            Assert.That(restored, Is.EqualTo(original));
        }
    }
}
