コード例 #1
0
        public void DetectAllProfanitiesReturnsNulListForEmptyInput()
        {
            var filter    = new ProfanityFilter();
            var swearList = filter.DetectAllProfanities(null);

            Assert.AreEqual(0, swearList.Count);
        }
コード例 #2
0
        public void DetectAllProfanitiesForEmptyString()
        {
            var filter = new ProfanityFilter();

            var swearList = filter.DetectAllProfanities("", true);

            Assert.AreEqual(0, swearList.Count);
        }
コード例 #3
0
        public void DetectAllProfanitiesScunthorpePenistone()
        {
            var filter = new ProfanityFilter();

            var swearList = filter.DetectAllProfanities("ScUnThOrPePeNiStOnE", true);

            Assert.AreEqual(0, swearList.Count);
        }
コード例 #4
0
        public void DetectAllProfanitiesMultipleScunthorpes()
        {
            var filter = new ProfanityFilter();

            var swearList = filter.DetectAllProfanities("Scunthorpe Scunthorpe", true);

            Assert.AreEqual(0, swearList.Count);
        }
コード例 #5
0
        public void DetectAllProfanitiesReturns1SwearPhrase()
        {
            var filter    = new ProfanityFilter();
            var swearList = filter.DetectAllProfanities("2 girls 1 cup is my favourite video");

            Assert.AreEqual(1, swearList.Count);
            Assert.AreEqual("2 girls 1 cup", swearList[0]);
        }
コード例 #6
0
        public void DetectAllProfanitiesForSingleWord()
        {
            var filter = new ProfanityFilter();

            var swearList = filter.DetectAllProfanities("c**k", true);

            Assert.AreEqual(1, swearList.Count);
            Assert.AreEqual("c**k", swearList[0]);
        }
コード例 #7
0
        public void DetectAllProfanitiesScunthorpePenistoneOneKnob()
        {
            var filter = new ProfanityFilter();

            var swearList = filter.DetectAllProfanities("ScUnThOrPePeNiStOnE KnOb", true);

            Assert.AreEqual(1, swearList.Count);
            Assert.AreEqual("knob", swearList[0]);
        }
コード例 #8
0
        public void DetectAllProfanitiesMultipleScunthorpesSingleCunt()
        {
            var filter = new ProfanityFilter();

            var swearList = filter.DetectAllProfanities("Scunthorpe c**t Scunthorpe", true);

            Assert.AreEqual(1, swearList.Count);
            Assert.AreEqual("c**t", swearList[0]);
        }
コード例 #9
0
        public void DetectAllProfanitiesReturns2SwearPhraseBecauseOfMatchDeduplication()
        {
            var filter    = new ProfanityFilter();
            var swearList = filter.DetectAllProfanities("2 girls 1 cup is my favourite twatting video", true);

            Assert.AreEqual(2, swearList.Count);
            Assert.AreEqual("2 girls 1 cup", swearList[0]);
            Assert.AreEqual("twatting", swearList[1]);
        }
コード例 #10
0
        public void DetectAllProfanitiesReturns2SwearWordsforMixedCase()
        {
            var filter    = new ProfanityFilter();
            var swearList = filter.DetectAllProfanities("You are a complete tWat and a DiCk.");

            Assert.AreEqual(2, swearList.Count);
            Assert.AreEqual("twat", swearList[1]);
            Assert.AreEqual("dick", swearList[0]);
        }
コード例 #11
0
        public void DetectAllProfanitiesReturns2SwearWordsWithCommas()
        {
            var filter    = new ProfanityFilter();
            var swearList = filter.DetectAllProfanities("You are, a complete twat, and a @dick:");

            Assert.AreEqual(2, swearList.Count);
            Assert.AreEqual("twat", swearList[1]);
            Assert.AreEqual("dick", swearList[0]);
        }
コード例 #12
0
        public void DetectAllProfanitiesScunthorpeWithDuplicatesTurnedOffAndNoAllowList()
        {
            var filter = new ProfanityFilter();

            var swearList = filter.DetectAllProfanities("I f*****g live in Scunthorpe and it is a shit place to live. I would much rather live in penistone you great big c**k f**k.", true);

            Assert.AreEqual(3, swearList.Count);
            Assert.AreEqual("c**k", swearList[1]);
            Assert.AreEqual("f*****g", swearList[0]);
            Assert.AreEqual("shit", swearList[2]);
        }
コード例 #13
0
        public void DetectAllProfanitiesBlocksAllowlist()
        {
            var filter = new ProfanityFilter();

            filter.AllowList.Add("tit");

            var swearList = filter.DetectAllProfanities("You are a complete twat and a total tit.", true);

            Assert.AreEqual(1, swearList.Count);
            Assert.AreEqual("twat", swearList[0]);
        }
コード例 #14
0
        public void DetectAllProfanitiesLongerSentence()
        {
            var filter = new ProfanityFilter();

            var swearList = filter.DetectAllProfanities("You are a stupid little twat, and you like to blow your load in an alaskan pipeline.", true);

            Assert.AreEqual(4, swearList.Count);
            Assert.AreEqual("alaskan pipeline", swearList[0]);
            Assert.AreEqual("blow your load", swearList[1]);
            Assert.AreEqual("stupid", swearList[2]);
            Assert.AreEqual("twat", swearList[3]);
        }
コード例 #15
0
        public void DetectAllProfanitiesScunthorpe()
        {
            var filter = new ProfanityFilter();

            filter.AllowList.Add("scunthorpe");
            filter.AllowList.Add("penistone");

            var swearList = filter.DetectAllProfanities("I f*****g live in Scunthorpe and it is a shit place to live. I would much rather live in penistone you great big c**k f**k.");

            Assert.AreEqual(4, swearList.Count);
            Assert.AreEqual("f*****g", swearList[0]);
            Assert.AreEqual("c**k", swearList[1]);
            Assert.AreEqual("f**k", swearList[2]);
            Assert.AreEqual("shit", swearList[3]);
        }