public void VerbotenChecker_WhenCheckingEmptyText_ShouldReturnTrue(string text)
        {
            IVerbotenPhraseProvider provider = Substitute.For<IVerbotenPhraseProvider>();
            VerbotenChecker checker = new VerbotenChecker(provider);

            var result = checker.ValidateText(text);

            Assert.AreEqual(result.IsSafeText, true);
        }
        public void VerbotenChecker_WhenCheckingTextWithoutVerbotenPhrases_ShouldReturnTrue()
        {
            var text = "This is a tweet containing good safe text";
            IVerbotenPhraseProvider provider = Substitute.For<IVerbotenPhraseProvider>();
            provider.GetVerbotenPhrases().ReturnsForAnyArgs(new List<string> { "Verboten2", "Verboten1" });
            VerbotenChecker checker = new VerbotenChecker(provider);

            var result = checker.ValidateText(text);

            Assert.AreEqual(result.IsSafeText, true);
        }
        public void VerbotenChecker_WhenCheckingTextWithVerbotenPhraseWithDifferentCase_ShouldReturnFalsePlusViolations()
        {
            var text = "This is a tweet containing verboten";
            IVerbotenPhraseProvider provider = Substitute.For<IVerbotenPhraseProvider>();
            provider.GetVerbotenPhrases().ReturnsForAnyArgs(new List<string> { "Verboten" });
            VerbotenChecker checker = new VerbotenChecker(provider);

            var result = checker.ValidateText(text);

            Assert.AreEqual(result.IsSafeText, false);
            Assert.AreEqual(result.Violations.Count, 1);
            Assert.AreEqual(result.Violations[0], "Verboten");
        }
        public void VerbotenChecker_WhenCheckingTextWithMultipleVerbotenPhrases_ShouldReturnFalsePlusViolations()
        {
            var text = "This is a tweet containing verboten1 and verboten2";
            IVerbotenPhraseProvider provider = Substitute.For<IVerbotenPhraseProvider>();
            provider.GetVerbotenPhrases().ReturnsForAnyArgs(new List<string> { "Verboten2", "Verboten1" });
            VerbotenChecker checker = new VerbotenChecker(provider);

            var result = checker.ValidateText(text);

            Assert.AreEqual(result.IsSafeText, false);
            Assert.AreEqual(result.Violations.Count, 2);
            Assert.IsTrue(result.Violations.Contains("Verboten1"));
            Assert.IsTrue(result.Violations.Contains("Verboten2"));
        }
        public ActionResult Index(Tweet tweet)
        {
            if (!ModelState.IsValid)
            {   
                return View(tweet);
            }

            var provider = new FixedVerbotenPhraseProvider();
            var checker = new VerbotenChecker(provider);

            var checkResponse = checker.ValidateText(tweet.Text);
            tweet.VerbotenCheckPassed = checkResponse.IsSafeText;
            tweet.Violations = checkResponse.Violations;

            return View(tweet);
        }
        public void VerbotenChecker_WhenCheckingTextWithVerbotenPhrasesOfNullOrWhiteSpace_ShouldReturnTrue()
        {
            var text = "This is a tweet containing verboten1 and verboten2";
            IVerbotenPhraseProvider provider = Substitute.For<IVerbotenPhraseProvider>();
            provider.GetVerbotenPhrases().ReturnsForAnyArgs(new List<string> { null,"","   " });
            VerbotenChecker checker = new VerbotenChecker(provider);

            var result = checker.ValidateText(text);

            Assert.AreEqual(result.IsSafeText, true);
        }