Пример #1
0
        public void MatchTest_Cache_MultiKeywords()
        {
            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinInitialsMatchProvider.GetName() }, false);
                string str     = "HelloWorld 你好世界!";
                var    cache   = matcher.CreateStringCache(str);

                Assert.IsTrue(matcher.Match(cache, new[] { "llow", "NH" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "llOW", "NH" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "llOW", "世界" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "世界", "!" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "nh", "!" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "世界", "!" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "X" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "  " }).IsMatchAllKeywords == false);
            }


            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinInitialsMatchProvider.GetName() }, true);
                string str     = "HelloWorld 你好世界!";
                var    cache   = matcher.CreateStringCache(str);

                Assert.IsTrue(matcher.Match(cache, new[] { "llow", "NH" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "llOW", "NH" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "llOW", "世界" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "世界" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "世界", "!" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "nh", "!" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "世界", "!" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "X" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "  " }).IsMatchAllKeywords == false);
            }

            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinMatchProvider.GetName() }, false);
                string str     = "HelloWorld 你好世界!";
                var    cache   = matcher.CreateStringCache(str);

                Assert.IsTrue(matcher.Match(cache, new[] { "llow", "NH" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "llOW", "NH" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "llOW", "世界" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "世界", "!" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "SHIJIE", "!" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "NI", "hao", "!" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "NI", "hao", "w" }).IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "世界", "!" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "X" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "lloW", "  " }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "a", " " }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { "a" }).IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, new[] { " " }).IsMatchAllKeywords == true);
            }
        }
Пример #2
0
        public void MatchTest_MatchCache_SingleKeyword()
        {
            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinInitialsMatchProvider.GetName() }, false);
                string str     = "HelloWorld 你好世界!";
                var    cache   = matcher.CreateStringCache(str);

                Assert.IsTrue(matcher.Match(cache, "llow").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "llOW").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "世界").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "!").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, " NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, " nH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "ld nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "ld NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "!").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "He l").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "  ").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "啊").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "a").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "X").IsMatchAllKeywords == false);
            }


            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinInitialsMatchProvider.GetName() }, true);
                string str     = "HelloWorld 你好世界!";
                var    cache   = matcher.CreateStringCache(str);

                Assert.IsTrue(matcher.Match(cache, "llow").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "lloW").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "世界").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "!").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, " NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, " nH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "ld nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "ld NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(cache, "lD nh").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "lD NH").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "!").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "He l").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "  ").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "啊").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(cache, "X").IsMatchAllKeywords == false);
            }
        }
Пример #3
0
        private static void LoadProviders()
        {
            if (AvailableProviders.ContainsKey(DirectMatchProvider.GetName()) == false)
            {
                AvailableProviders.Add(DirectMatchProvider.GetName(), new DirectMatchProvider(false));
            }
            if (AvailableProviders.ContainsKey(InitialsMatchProvider.GetName()) == false)
            {
                AvailableProviders.Add(InitialsMatchProvider.GetName(), new InitialsMatchProvider(false));
            }
            if (AvailableProviders.ContainsKey(DiscreteMatchProvider.GetName()) == false)
            {
                AvailableProviders.Add(DiscreteMatchProvider.GetName(), new DiscreteMatchProvider(false));
            }
            if (AvailableProviders.ContainsKey(ChineseZhCnPinYinInitialsMatchProvider.GetName()) == false)
            {
                AvailableProviders.Add(ChineseZhCnPinYinInitialsMatchProvider.GetName(), new ChineseZhCnPinYinInitialsMatchProvider(false));
            }
            if (AvailableProviders.ContainsKey(ChineseZhCnPinYinMatchProvider.GetName()) == false)
            {
                AvailableProviders.Add(ChineseZhCnPinYinMatchProvider.GetName(), new ChineseZhCnPinYinMatchProvider(false));
            }

            try
            {
                var files = Directory.GetFiles(Directory.GetParent(typeof(Builder).Assembly.Location).FullName, "*.dll");
                foreach (var dllPath in files)
                {
                    var assembly  = Assembly.LoadFile(dllPath);
                    var types     = assembly.GetTypes();
                    var providers = types.Where(item =>
                                                item.IsSubclassOf(typeof(MatchProviderBase)) && !item.IsAbstract)
                                    .Select(type => CreateProviderInstance(type, false));

                    foreach (var provider in providers.OrderBy(x => x.GetProviderDescription()))
                    {
                        var t = provider.GetProviderName();
                        if (AvailableProviders.ContainsKey(t) == false)
                        {
                            AvailableProviders.Add(t, provider);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Пример #4
0
        public void MatchsTestCase()
        {
            List <MatchCache> caches = new List <MatchCache>();

            caches.Add(new MatchCache("HelloWorld 你好世界!"));
            caches.Add(new MatchCache("NH 1234"));

            var matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinMatchProvider.GetName() }, true);

            {
                var r = matcher.Matchs(caches, new string[] { "Hell", "123" });
                Assert.IsTrue(r.IsMatchAllKeywords);
                Assert.IsTrue(r.HitFlags[0][0] == true &&
                              r.HitFlags[0][1] == true &&
                              r.HitFlags[0][2] == true &&
                              r.HitFlags[0][3] == true &&
                              r.HitFlags[0][4] == false &&
                              r.HitFlags[0][5] == false &&
                              r.HitFlags[1][0] == false &&
                              r.HitFlags[1][1] == false &&
                              r.HitFlags[1][2] == false &&
                              r.HitFlags[1][3] == true &&
                              r.HitFlags[1][4] == true &&
                              r.HitFlags[1][5] == true &&
                              r.HitFlags[1][6] == false
                              );
            }

            {
                var r = matcher.Matchs(caches, new string[] { "hell", "123" });
                Assert.IsTrue(r.IsMatchAllKeywords == false);
                Assert.IsTrue(r.HitFlags[0][0] == false &&
                              r.HitFlags[0][1] == false &&
                              r.HitFlags[0][2] == false &&
                              r.HitFlags[0][3] == false &&
                              r.HitFlags[0][4] == false &&
                              r.HitFlags[0][5] == false &&
                              r.HitFlags[1][0] == false &&
                              r.HitFlags[1][1] == false &&
                              r.HitFlags[1][2] == false &&
                              r.HitFlags[1][3] == true &&
                              r.HitFlags[1][4] == true &&
                              r.HitFlags[1][5] == true &&
                              r.HitFlags[1][6] == false
                              );
            }
        }
Пример #5
0
        public void GetProviderDescriptionTest()
        {
            {
                var dsp1 = Builder.GetProviderDescription(DirectMatchProvider.GetName());
                var dsp2 = Builder.GetProviderDescriptionEn(DirectMatchProvider.GetName());
                Assert.IsTrue(!string.IsNullOrEmpty(dsp1));
                Assert.IsTrue(!string.IsNullOrEmpty(dsp2));
            }
            {
                var dsp1 = Builder.GetProviderDescription(InitialsMatchProvider.GetName());
                var dsp2 = Builder.GetProviderDescriptionEn(InitialsMatchProvider.GetName());
                Assert.IsTrue(!string.IsNullOrEmpty(dsp1));
                Assert.IsTrue(!string.IsNullOrEmpty(dsp2));
            }
            {
                var dsp1 = Builder.GetProviderDescription(DiscreteMatchProvider.GetName());
                var dsp2 = Builder.GetProviderDescriptionEn(DiscreteMatchProvider.GetName());
                Assert.IsTrue(!string.IsNullOrEmpty(dsp1));
                Assert.IsTrue(!string.IsNullOrEmpty(dsp2));
            }
            {
                var dsp1 = Builder.GetProviderDescription(ChineseZhCnPinYinMatchProvider.GetName());
                var dsp2 = Builder.GetProviderDescriptionEn(ChineseZhCnPinYinMatchProvider.GetName());
                Assert.IsTrue(!string.IsNullOrEmpty(dsp1));
                Assert.IsTrue(!string.IsNullOrEmpty(dsp2));
            }
            {
                var dsp1 = Builder.GetProviderDescription(ChineseZhCnPinYinInitialsMatchProvider.GetName());
                var dsp2 = Builder.GetProviderDescriptionEn(ChineseZhCnPinYinInitialsMatchProvider.GetName());
                Assert.IsTrue(!string.IsNullOrEmpty(dsp1));
                Assert.IsTrue(!string.IsNullOrEmpty(dsp2));
            }
#if !NET45
            {
                var dsp1 = Builder.GetProviderDescription(JapaneseRomajiProvider.GetName());
                var dsp2 = Builder.GetProviderDescriptionEn(JapaneseRomajiProvider.GetName());
                Assert.IsTrue(!string.IsNullOrEmpty(dsp1));
                Assert.IsTrue(!string.IsNullOrEmpty(dsp2));
            }
#endif
        }
Пример #6
0
        public void MatchTest_String_SingleKeyword()
        {
            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName() }, false);
                string str     = "HelloWorld 你好世界!";

                Assert.IsTrue(matcher.Match(str, "llow").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "llOW").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "世界").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "!").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "!").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "He l").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "  ").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "啊").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "X").IsMatchAllKeywords == false);
            }

            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinInitialsMatchProvider.GetName() }, false);
                string str     = "HelloWorld 你好世界!";

                Assert.IsTrue(matcher.Match(str, "llow").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "llOW").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "世界").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "!").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, " NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, " nH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "ld nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "ld NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "!").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "He l").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "  ").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "啊").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "X").IsMatchAllKeywords == false);
            }


            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinInitialsMatchProvider.GetName() }, true);
                string str     = "HelloWorld 你好世界!";

                Assert.IsTrue(matcher.Match(str, "llow").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "lloW").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "世界").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "!").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, " NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, " nH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "ld nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "ld NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "lD nh").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "lD NH").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "!").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "He l").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "  ").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "啊").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "X").IsMatchAllKeywords == false);
            }


            {
                var    matcher = Builder.Build(new[] { DirectMatchProvider.GetName(), ChineseZhCnPinYinInitialsMatchProvider.GetName(), ChineseZhCnPinYinMatchProvider.GetName() }, false);
                string str     = "HelloWorld 你好世界!";

                Assert.IsTrue(matcher.Match(str, "llow").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "llOW").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "世界").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "SHIJIE").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "!").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, " NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, " nH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "ld nh").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "ld NH").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "ld NIHA").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "ld NIHAo").IsMatchAllKeywords == true);
                Assert.IsTrue(matcher.Match(str, "!").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "He l").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "  ").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "啊").IsMatchAllKeywords == false);
                Assert.IsTrue(matcher.Match(str, "X").IsMatchAllKeywords == false);
            }
        }
        public void DoMatchesTest()
        {
            var matcher1 = new DirectMatchProvider(false);
            var matcher2 = new ChineseZhCnPinYinInitialsMatchProvider(false);
            var test     = new MatchCache("多重hello world");

            matcher1.AppendDescriptions(ref test);
            matcher2.AppendDescriptions(ref test);

            {
                bool throwException = false;
                try
                {
                    var ret = matcher1.DoMatches(new MatchCache("123"), new List <string>()
                    {
                        "dc"
                    });
                    var ret2 = matcher1.DoMatches(new MatchCache("abc"), new List <string>()
                    {
                        "dc"
                    });
                    ret.Merge(ret2);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throwException = true;
                }

                Assert.IsTrue(throwException);
            }

            {
                var ret = matcher1.DoMatches(test, new List <string>()
                {
                    "dc"
                });
                var ret2 = matcher2.DoMatches(test, new List <string>()
                {
                    "dc"
                });
                ret.Merge(ret2);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "dc");
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == test.StringLength &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false &&
                              m[6] == false &&
                              m[7] == false &&
                              m[8] == false &&
                              m[9] == false &&
                              m[10] == false &&
                              m[11] == false &&
                              m[12] == false);
            }

            {
                var kws = new List <string>()
                {
                    "dc"
                };
                var ret  = matcher1.DoMatches(test, kws);
                var ret2 = matcher2.DoMatches(test, kws);
                ret.Merge(ret2);
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "dc");
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == test.StringLength &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false &&
                              m[6] == false &&
                              m[7] == false &&
                              m[8] == false &&
                              m[9] == false &&
                              m[10] == false &&
                              m[11] == false &&
                              m[12] == false);
            }


            {
                var ret = matcher1.DoMatches(test, new List <string>()
                {
                    "wor"
                });
                var ret2 = matcher2.DoMatches(test, new List <string>()
                {
                    "Dc"
                });
                ret.Merge(ret2);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(ret.Keywords.Count == 2 && ret.Keywords.Any(x => x == "Dc") && ret.Keywords.Any(x => x == "wor"));
                Assert.IsTrue(m.Count == test.StringLength &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false &&
                              m[6] == false &&
                              m[7] == false &&
                              m[8] == true &&
                              m[9] == true &&
                              m[10] == true &&
                              m[11] == false &&
                              m[12] == false);
            }

            {
                var ret = matcher2.DoMatches(test, new List <string>()
                {
                    "dc"
                });
                ret.Merge(matcher1.DoMatches(test, new List <string>()
                {
                    "wor", "abs"
                }));
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
                Assert.IsTrue(ret.Keywords.Count == 3);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == test.StringLength &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false &&
                              m[6] == false &&
                              m[7] == false &&
                              m[8] == true &&
                              m[9] == true &&
                              m[10] == true &&
                              m[11] == false &&
                              m[12] == false);
            }
        }
        public void DoMatchesTest()
        {
            var matcher     = new DirectMatchProvider(false);
            var matcherCase = new DirectMatchProvider(true);

            Assert.IsTrue(matcher.GetProviderName() == nameof(DirectMatchProvider));
            var dspen = matcher.GetProviderDescriptionEn();
            var dsp   = matcher.GetProviderDescription();

            {
                var ret = matcher.DoMatches(new MatchCache(""), new[] { "" });
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
            }

            {
                string org = "abcdefg";
                var    str = new MatchCache(org);
                matcher.AppendDescriptions(ref str);
                matcherCase.AppendDescriptions(ref str);
            }

            {
                string org = "abcdefg";
                var    kws = new[] { "a" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "a");
                Assert.IsTrue(m.Count == org.Length && m[0] == true && m[1] == false);
            }

            {
                string org = "abcdefg";
                var    kws = new[] { "A" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "A");
                Assert.IsTrue(m.Count == org.Length && m[0] == true && m[1] == false);
            }

            {
                string org = "abcdefg";
                var    kws = new[] { "a" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "a");
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length && m[0] == true && m[1] == false);
            }

            {
                string org = "abcdefg";
                var    kws = new[] { "A" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.Keywords.Count == 1 && ret.Keywords[0] == "A");
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
                var m = ret.HitFlags;
                Assert.IsTrue(m.All(x => x == false));
            }

            {
                string org = "abcdefgabcdefg";
                var    kws = new[] { "defg", "abc" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m.All(x => x == true));
            }

            {
                string org = "abcDefgabcdefg";
                var    kws = new[] { "Defg", "abc" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              !m.All(x => x == true));
            }

            {
                string org = "abaaa";
                var    kws = new[] { "aa" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == true);
            }
            {
                string org = "abaa a";
                var    kws = new[] { "aa" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == false &&
                              m[5] == false);
            }
            {
                string org = "abaa a";
                var    kws = new[] { " " };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == true &&
                              m[5] == false);
            }
            {
                string org = "abAAa";
                var    kws = new[] { "aa" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == true);
            }

            {
                string org = "abAA a";
                var    kws = new[] { "aa" };
                var    ret = matcher.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == false &&
                              m[5] == false);
            }

            {
                string org = "abAA a";
                var    kws = new[] { "aA" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
            }

            {
                string org = "abAA a";
                var    kws = new[] { "AA" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == true);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == false &&
                              m[1] == false &&
                              m[2] == true &&
                              m[3] == true &&
                              m[4] == false &&
                              m[5] == false);
            }



            {
                string org = "abAA a";
                var    kws = new[] { "ab", "AB" };
                var    ret = matcherCase.DoMatches(new MatchCache(org), kws);
                Assert.IsTrue(ret.IsMatchAllKeywords == false);
                var m = ret.HitFlags;
                Assert.IsTrue(m.Count == org.Length &&
                              m[0] == true &&
                              m[1] == true &&
                              m[2] == false &&
                              m[3] == false &&
                              m[4] == false &&
                              m[5] == false);
            }
        }