Example #1
0
        public void TestCaseSensitive()
        {
            var matcher = SimpleQuery.Compile(@"""word1""");

            Assert.True(matcher("word1"));
            Assert.False(matcher("Word1"));
        }
Example #2
0
        public void TestNotCondition()
        {
            var matcher = SimpleQuery.Compile(@"NOT ""word3""");

            Assert.True(matcher("word1"));
            Assert.False(matcher("word3"));
        }
Example #3
0
        public void TestSingleCondition()
        {
            var matcher = SimpleQuery.Compile(@"""word1"" OR ""word2""");

            Assert.True(matcher("word1"));
            Assert.True(matcher("word2"));
            Assert.False(matcher("word3"));
        }
Example #4
0
        public void TestSimplePhrase()
        {
            var matcher = SimpleQuery.Compile(@"""multi word""");

            Assert.True(matcher("multi word"));
            Assert.True(matcher("inner multi word inner"));
            Assert.False(matcher("inner multi test word inner"));
        }
Example #5
0
        public void TestMultipleConditions()
        {
            var matcher = SimpleQuery.Compile(@"(""word1 space"" OR word2) AND ""word3""");

            Assert.False(matcher("word1 word3"));
            Assert.True(matcher("word1 space word3"));
            Assert.True(matcher("word2 word3"));
            Assert.False(matcher("word3"));
        }
Example #6
0
        public void TestDelimiterParentheses()
        {
            var matcher = SimpleQuery.Compile(@"((word1 space) OR word2) AND (word3)", new SimpleQuery.Options()
            {
                PhraseDelimiterMode = PhraseDelimiterMode.Parentheses
            });

            Assert.False(matcher("word1 word3"));
            Assert.True(matcher("word1 space word3"));
            Assert.True(matcher("word2 word3"));
            Assert.False(matcher("word3"));
        }
Example #7
0
        public void TestSimple()
        {
            var matcher = SimpleQuery.Compile(@"""word1""");

            Assert.True(matcher("word1"));
            Assert.False(matcher("word2"));

            var matcher2 = SimpleQuery.Compile(@"word1");

            Assert.True(matcher2("word1"));
            Assert.False(matcher2("word2"));
        }
Example #8
0
        public void TestCaseInsensitive()
        {
            var matcher = SimpleQuery.Compile(@"""word1"" OR ""Word2""", new SimpleQuery.Options()
            {
                CaseSensitive = false,
            });

            Assert.True(matcher("word1"));
            Assert.True(matcher("Word1"));
            Assert.True(matcher("word2"));
            Assert.True(matcher("Word2"));
            Assert.False(matcher("Word3"));
        }