// ---------------------------------------------------------------------------
// BT.Framework.Tests
// AttributeTests.cs — ReadOnly/ShowIf/ArrayTitle 속성 단위 테스트
// ---------------------------------------------------------------------------
using System;
using NUnit.Framework;
using BurningTimes.Core.Attribute;

namespace BurningTimes.Tests.Core.Attribute
{
    public class AttributeTests
    {
        [Test]
        public void ReadOnlyAttribute_IsSealedAndFieldOnly()
        {
            var t = typeof(ReadOnlyAttribute);
            Assert.IsTrue(t.IsSealed);
            var usage = (AttributeUsageAttribute)Attribute.GetCustomAttribute(t, typeof(AttributeUsageAttribute));
            Assert.IsNotNull(usage);
            Assert.That(usage.ValidOn, Is.EqualTo(AttributeTargets.Field));
            Assert.IsFalse(usage.AllowMultiple);
        }

        [Test]
        public void ShowIfAttribute_TruthyConstructor_SetsMemberNameAndNullExpected()
        {
            var attr = new ShowIfAttribute("_flag");
            Assert.That(attr.MemberName, Is.EqualTo("_flag"));
            Assert.IsNull(attr.ExpectedValue);
            Assert.IsTrue(attr.HideInInspector);
        }

        [Test]
        public void ShowIfAttribute_ValueConstructor_SetsExpectedValue()
        {
            var attr = new ShowIfAttribute("_mode", 2);
            Assert.That(attr.MemberName, Is.EqualTo("_mode"));
            Assert.That(attr.ExpectedValue, Is.EqualTo(2));
        }

        [Test]
        public void ShowIfAttribute_HideInInspectorOverridable()
        {
            var attr = new ShowIfAttribute("_flag", hideInInspector: false);
            Assert.IsFalse(attr.HideInInspector);
        }

        [Test]
        public void ArrayTitleAttribute_DefaultPrefixIsEmpty()
        {
            var attr = new ArrayTitleAttribute("Name");
            Assert.That(attr.MemberName, Is.EqualTo("Name"));
            Assert.That(attr.Prefix, Is.EqualTo(string.Empty));
        }

        [Test]
        public void ArrayTitleAttribute_PrefixStored()
        {
            var attr = new ArrayTitleAttribute("Name", "Card");
            Assert.That(attr.Prefix, Is.EqualTo("Card"));
        }

        [Test]
        public void ArrayTitleAttribute_NullPrefixCoercedToEmpty()
        {
            var attr = new ArrayTitleAttribute("Name", null);
            Assert.That(attr.Prefix, Is.EqualTo(string.Empty));
        }
    }
}
