Exemplo n.º 1
0
        public void checkPhraseFoundSimpleTest()
        {
            string BodyContent = "This text has baDword and \"2wronGword\" and nonOword3 wroNgworK";
            string context = "", allContexts = "";

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

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

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

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

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

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

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

            areTrue(FilterPolicy.checkPhraseFoundSimple(BodyContent, new PhraseFilter()
            {
                Phrase = "wrongwor[tk]",
                Type   = BlockPhraseType.REGEX
            }, out context)); allContexts += context + '\n';

            //Console.Write(allContexts);
        }