using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NavisworksTransport.Utils;

namespace NavisworksTransport.UnitTests.Core
{
    [TestClass]
    public class SelectionClipBoxLockStateTests
    {
        [TestMethod]
        public void ShouldRefreshOnSelectionChanged_ReturnsFalse_WhenSelectionClipBoxIsLocked()
        {
            var state = new SelectionClipBoxLockState();
            state.LockSelection(new object[] { new object(), new object() });

            bool shouldRefresh = state.ShouldRefreshOnSelectionChanged(isSelectionClipBoxMode: true);

            Assert.IsFalse(shouldRefresh);
            Assert.AreEqual(2, state.LockedSelectionCount);
        }

        [TestMethod]
        public void ShouldRefreshOnSelectionChanged_ReturnsTrue_WhenSelectionClipBoxModeHasNoLockedSelection()
        {
            var state = new SelectionClipBoxLockState();

            bool shouldRefresh = state.ShouldRefreshOnSelectionChanged(isSelectionClipBoxMode: true);

            Assert.IsTrue(shouldRefresh);
            Assert.AreEqual(0, state.LockedSelectionCount);
        }

        [TestMethod]
        public void Clear_UnlocksSelectionClipBoxState()
        {
            var state = new SelectionClipBoxLockState();
            state.LockSelection(new List<object> { new object() });

            state.Clear();

            Assert.IsFalse(state.IsLocked);
            Assert.AreEqual(0, state.LockedSelectionCount);
        }
    }
}
