示例#1
0
            public TestSetup()
            {
                var dataContext = new FakeDataContext();

                BadWordsRepository   = new Repository <BadWord>(dataContext);
                CacheMock            = new TestCacheManager().CacheMock;
                ResourcesServiceMock = new Mock <IResourcesService>();
                ResourcesServiceMock.Setup(x => x.GetString(It.IsAny <string>(), It.IsAny <string>())).Returns(ANY_RESOURCE_STRING);

                ProfanityService = new ProfanityService(CacheMock.Object, BadWordsRepository, ResourcesServiceMock.Object);
            }
        public void z1()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasBadWords("last word is p**n");

            // Assert
            Assert.IsTrue(actual);
        }
        public void HandleSpaceBeforeAndAfter()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasBadWords(" p**n ");

            // Assert
            Assert.IsTrue(actual);
        }
        public void HandleWordByItself()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasBadWords("p**n");

            // Assert
            Assert.IsTrue(actual);
        }
        public void Embedded()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasBadWords("notpornisit");

            // Assert
            Assert.IsFalse(actual);
        }
        public void Hyphenated()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasBadWords("p**n-ish");

            // Assert
            Assert.IsTrue(actual);
        }
        public void ReturnTrueWhenUrlFound()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasUrl("click this http://www.foufos.gr/kino");

            // Assert
            Assert.IsTrue(actual);
        }
        public void ReturnFalseWhenUrlNotFound()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasUrl("click this link");

            // Assert
            Assert.IsFalse(actual);
        }
示例#9
0
        public void ReturnFalseWhenEnglish()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasNonEnglish("this text should be okay");

            // Assert
            Assert.IsFalse(actual);
        }
示例#10
0
        public void ReturnTrueWhenCryllic()
        {
            // Arrange
            var badwords = new[] { "p**n" };
            var service  = new ProfanityService(badwords);

            // Act
            var actual = service.HasNonEnglish("Регистрация");

            // Assert
            Assert.IsTrue(actual);
        }