IsMatch() 공개 메소드

Determines whether the specified request matches the rule.
public IsMatch ( IStumpsHttpRequest request ) : bool
request IStumpsHttpRequest The to evaluate.
리턴 bool
예제 #1
0
        public void InitializeFromSettings_WithValidSettings_MatchesCorrectly()
        {
            var settings = new[]
            {
                new RuleSetting {
                    Name = "text.evaluation", Value = "passed"
                },
                new RuleSetting {
                    Name = string.Empty, Value = string.Empty
                },
                new RuleSetting {
                    Name = null, Value = string.Empty
                },
                new RuleSetting {
                    Name = "text.evaluation", Value = string.Empty
                }
            };

            var rule = new BodyContentRule();

            rule.InitializeFromSettings(settings);

            Assert.IsTrue(rule.IsInitialized);

            var request = CreateTextRequest("passed");

            Assert.IsTrue(rule.IsMatch(request));
        }
예제 #2
0
        public void IsMatch_NullContext_ReturnsFalse()
        {
            var rule = new BodyContentRule(
                new string[]
            {
                "passed"
            });

            Assert.IsFalse(rule.IsMatch(null));
        }
예제 #3
0
        public void IsMatch_RegexTextWithNonMatchingString_ReturnsFalse()
        {
            var rule = new BodyContentRule(
                new string[]
            {
                "regex:AA.*ssed.*D"
            });

            var request = CreateTextRequest("failed");

            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #4
0
        public void IsMatch_ContainsTextWithMatchingString_ReturnsTrue()
        {
            var rule = new BodyContentRule(
                new string[]
            {
                "passed", "AAA"
            });

            var request = CreateTextRequest("passed");

            Assert.IsTrue(rule.IsMatch(request));
        }
예제 #5
0
        public void IsMatch_ContainsTextInversedWithNonMatchingText_ReturnsFalse()
        {
            var rule = new BodyContentRule(
                new string[]
            {
                "not:passed"
            });

            var request = CreateTextRequest("passed");

            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #6
0
        public void IsMatch_BinaryContentWithTextString_ReturnsFalse()
        {
            var request = CreateBinaryRequest();

            var rule = new BodyContentRule(
                new string[]
            {
                "passed"
            });

            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #7
0
        public void IsMatch_WithoutBody_ReturnsFalse()
        {
            var request = Substitute.For <IStumpsHttpRequest>();

            request.BodyLength.Returns(0);

            var rule = new BodyContentRule(
                new string[]
            {
                "passed"
            });

            Assert.IsFalse(rule.IsMatch(null));
        }
예제 #8
0
        public void InitializeFromSettings_WithValidSettings_MatchesCorrectly()
        {
            var settings = new[]
            {
                new RuleSetting { Name = "text.evaluation", Value = "passed" },
                new RuleSetting { Name = string.Empty, Value = string.Empty },
                new RuleSetting { Name = null, Value = string.Empty },
                new RuleSetting { Name = "text.evaluation", Value = string.Empty }
            };

            var rule = new BodyContentRule();
            rule.InitializeFromSettings(settings);

            Assert.IsTrue(rule.IsInitialized);

            var request = CreateTextRequest("passed");
            Assert.IsTrue(rule.IsMatch(request));
        }
예제 #9
0
        public void IsMatch_ContainsTextWithNonMatchingString_ReturnsFalse()
        {
            var ruleCaseMatches = new BodyContentRule(
                new string[]
            {
                "failed", "AAA"
            });

            var ruleCaseDoesNotMatch = new BodyContentRule(
                new string[]
            {
                "PASSED", "AAA"
            });

            var request = CreateTextRequest("passed");

            Assert.IsFalse(ruleCaseMatches.IsMatch(request));

            // correct text, wrong case
            Assert.IsFalse(ruleCaseDoesNotMatch.IsMatch(request));
        }
예제 #10
0
        public void IsMatch_ContainsTextInversedWithMatchingText_ReturnsTrue()
        {
            var rule = new BodyContentRule(
                new string[]
                {
                    "not:failed"
                });

            var request = CreateTextRequest("passed");
            Assert.IsTrue(rule.IsMatch(request));
        }
예제 #11
0
        public void IsMatch_BinaryContentWithTextString_ReturnsFalse()
        {
            var request = CreateBinaryRequest();

            var rule = new BodyContentRule(
                new string[]
                {
                    "passed"
                });

            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #12
0
        public void IsMatch_WithoutBody_ReturnsFalse()
        {
            var request = Substitute.For<IStumpsHttpRequest>();
            request.BodyLength.Returns(0);

            var rule = new BodyContentRule(
                new string[]
                {
                    "passed"
                });

            Assert.IsFalse(rule.IsMatch(null));
        }
예제 #13
0
        public void IsMatch_RegexTextWithNonMatchingString_ReturnsFalse()
        {
            var rule = new BodyContentRule(
                new string[]
                {
                    "regex:AA.*ssed.*D"
                });

            var request = CreateTextRequest("failed");
            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #14
0
        public void IsMatch_NullContext_ReturnsFalse()
        {
            var rule = new BodyContentRule(
                new string[]
                {
                    "passed"
                });

            Assert.IsFalse(rule.IsMatch(null));
        }
예제 #15
0
        public void IsMatch_ContainsTextWithNonMatchingString_ReturnsFalse()
        {
            var ruleCaseMatches = new BodyContentRule(
                new string[]
                {
                    "failed", "AAA"
                });

            var ruleCaseDoesNotMatch = new BodyContentRule(
                new string[]
                {
                    "PASSED", "AAA"
                });

            var request = CreateTextRequest("passed");

            Assert.IsFalse(ruleCaseMatches.IsMatch(request));

            // correct text, wrong case
            Assert.IsFalse(ruleCaseDoesNotMatch.IsMatch(request));
        }
예제 #16
0
        public void IsMatch_ContainsTextWithMatchingString_ReturnsTrue()
        {
            var rule = new BodyContentRule(
                new string[]
                {
                    "passed", "AAA"
                });

            var request = CreateTextRequest("passed");
            Assert.IsTrue(rule.IsMatch(request));
        }