Exemplo n.º 1
0
        public void checkPhraseFoundWordTest()
        {
            string        context = "", allContexts = "";
            string        BodyContent = "This text has baDword and \"2wronGword\" and nonOword3 wroNgworK";
            List <string> words       = FilterPolicy.getWords(BodyContent);

            areFalse(FilterPolicy.checkPhraseFoundWord(words, new PhraseFilter()
            {
                Phrase = "text",
                Type   = BlockPhraseType.CONTAIN // Not supported in checkPhraseFoundWord
            }, out context)); allContexts += context + '\n';

            areFalse(FilterPolicy.checkPhraseFoundWord(words, new PhraseFilter()
            {
                Phrase = "",
                Type   = BlockPhraseType.WORDCONTAINING
            }, out context)); allContexts += context + '\n';

            areFalse(FilterPolicy.checkPhraseFoundWord(words, new PhraseFilter()
            {
                Phrase = "",
                Type   = BlockPhraseType.EXACTWORD
            }, out context)); allContexts += context + '\n';

            areFalse(FilterPolicy.checkPhraseFoundWord(words, new PhraseFilter()
            {
                Phrase = "notfound",
                Type   = BlockPhraseType.WORDCONTAINING
            }, out context)); allContexts += context + '\n';

            areTrue(FilterPolicy.checkPhraseFoundWord(words, new PhraseFilter()
            {
                Phrase = "badword",
                Type   = BlockPhraseType.EXACTWORD
            }, out context)); allContexts += context + '\n';

            areTrue(FilterPolicy.checkPhraseFoundWord(words, new PhraseFilter()
            {
                Phrase = "wrongword",
                Type   = BlockPhraseType.EXACTWORD
            }, out context)); allContexts += context + '\n';

            areTrue(FilterPolicy.checkPhraseFoundWord(words, new PhraseFilter()
            {
                Phrase = "nonoword",
                Type   = BlockPhraseType.EXACTWORD
            }, out context)); allContexts += context + '\n';

            areTrue(FilterPolicy.checkPhraseFoundWord(words, new PhraseFilter()
            {
                Phrase = "rongwor",
                Type   = BlockPhraseType.WORDCONTAINING
            }, out context)); allContexts += context + '\n';

            //Console.Write(allContexts);
        }