using NUnit.Framework;

namespace Jovian.TagSystem.Tests {
    public class TestJovianTagsGroup {
        private const string TAG_ONE = "Test";
        private const int EXPECTED_TAG_ID = 1;

        [SetUp]
        public void Setup() {
            var tags = new RegisteredTag[] { new(TAG_ONE) };
            JovianTagsHandler.Initialize();
            JovianTagsHandler.RegisterTags(tags);
        }

        [Test]
        public void GivenSelectionWithTag_WhenContains_ThenTrue() {
            var selection = new JovianTagsGroup(TAG_ONE);
            var resolved = JovianTagsHandler.GetTag(TAG_ONE);
            Assert.IsTrue(selection.Contains(resolved));
        }

        [Test]
        public void GivenSelectionWithoutTag_WhenContains_ThenFalse() {
            var selection = new JovianTagsGroup("NonExistent");
            var resolved = JovianTagsHandler.GetTag(TAG_ONE);
            Assert.IsFalse(selection.Contains(resolved));
        }

        [Test]
        public void GivenMultipleTags_WhenToContainer_ThenAllResolved() {
            JovianTagsHandler.RegisterTag("Other");
            var selection = new JovianTagsGroup(TAG_ONE, "Other");
            var container = selection.ToContainer();
            Assert.AreEqual(2, container.Count);
        }

        [Test]
        public void GivenSelection_WhenHasAny_ThenCorrect() {
            Assert.IsTrue(new JovianTagsGroup(TAG_ONE).HasAny());
            Assert.IsFalse(new JovianTagsGroup().HasAny());
        }

        [TearDown]
        public void Dispose() {
            JovianTagsHandler.Reset();
        }
    }
}
