using Quadarax.Foundation.Core.Value;

namespace qdr.fnd.core.test
{
    public class StringPatternComparerTest
    {

        private StringPatternComparer? _comparer;
        private string _testSource = "* Dalibor Votruba 1976 *";
        [SetUp]
        public void Setup()
        {
            _comparer = new StringPatternComparer();
        }

        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsAnyTextAny()
        {
            var pattern = "*Dalibor*";
            var result = _comparer?.Equals(_testSource, pattern);
            Assert.IsTrue(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsAnySpaceTextAny()
        {
            var pattern = "*_Dalibor*";
            var result = _comparer?.Equals(_testSource, pattern);
            Assert.IsTrue(result);
        }

        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsEscTextAny()
        {
            var pattern = "/* Dalibor*";
            var result = _comparer?.Equals(_testSource, pattern);
            Assert.IsTrue(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsEscTextSpaceAlphaNumNumAny()
        {
            var pattern = "/* Dalibor_?#*";
            var result = _comparer?.Equals(_testSource, pattern);
            Assert.IsTrue(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsAnySpaceEscText()
        {
            var pattern = "*_/*";
            var result = _comparer?.Equals(_testSource, pattern);
            Assert.IsTrue(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsAnyNumericAny()
        {
            var pattern = "*#*";
            var result = _comparer?.Equals(_testSource, pattern);
            Assert.IsTrue(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void NotEqualsEmptyPattern()
        {
            var pattern = string.Empty;
            var result = _comparer?.Equals(_testSource, pattern);
            Assert.IsFalse(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void NotEqualsOccurences()
        {
            var pattern = "*Da#*V*";
            var result = _comparer?.Equals(_testSource, pattern);
            Assert.IsFalse(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsEmptySource()
        {
            var pattern = string.Empty;
            var source = string.Empty;
            var result = _comparer?.Equals(source, pattern);
            Assert.IsTrue(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsNullSourceNullPattern()
        {
            string? pattern = null;
            string? source = null;
            var result = _comparer?.Equals(source, pattern);
            Assert.IsTrue(result);
        }
        [Test(TestOf = typeof(StringPatternComparer))]
        public void EqualsSourceShorterThanPattern()
        {
            var pattern = "*A";
            var source = "A";
            var result = _comparer?.Equals(source, pattern);
            Assert.IsTrue(result);
        }
    }
}