A class representing a Stump rule that evaluates the URL of an HTTP request.
Inheritance: IStumpRule
Ejemplo n.º 1
0
        public void GetRuleSettings_WhenCalled_ReturnsList()
        {
            var rule = new UrlRule("a");
            var list = new List <RuleSetting>(rule.GetRuleSettings());

            Assert.AreEqual(1, list.Count);
        }
Ejemplo n.º 2
0
        public void InitializeFromSettings_WithNullSettings_ThrowsException()
        {
            var rule = new UrlRule();

            Assert.That(
                () => rule.InitializeFromSettings(null),
                Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("settings"));
        }
Ejemplo n.º 3
0
        public void InitializeFromSettings_WithNullSettings_ThrowsException()
        {
            var rule = new UrlRule();

            Assert.That(
                () => rule.InitializeFromSettings(null),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("settings"));
        }
Ejemplo n.º 4
0
        public void IsMatch_ExactTextRuleInversedWithMatchingString_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/failed/"
            };

            var rule = new UrlRule("not:/failed/");
            Assert.IsFalse(rule.IsMatch(request));
        }
Ejemplo n.º 5
0
        public void IsMatch_RegexRuleWithNonMatchingString_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/failed/"
            };

            var rule = new UrlRule("regex:as*ed");

            Assert.IsFalse(rule.IsMatch(request));
        }
Ejemplo n.º 6
0
        public void IsMatch_ExactTextRuleInversedWithNonMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/passed/"
            };

            var rule = new UrlRule("not:/failed/");

            Assert.IsTrue(rule.IsMatch(request));
        }
Ejemplo n.º 7
0
        public void InitializeFromSettings_WithValidSettings_InitializesCorrectly(string httpMethod, string expectedHttpMethod)
        {
            var settings = new[]
            {
                new RuleSetting { Name = "url.value", Value = httpMethod }
            };

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

            Assert.IsTrue(rule.IsInitialized);
            Assert.AreEqual(expectedHttpMethod, rule.UrlTextMatch);
        }
Ejemplo n.º 8
0
        public void IsMatch_NullValue_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                RawUrl = null
            };

            var rule = new UrlRule(null);

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

            rule = new UrlRule("/test");
            Assert.IsFalse(rule.IsMatch(request));
        }
Ejemplo n.º 9
0
        public void IsMatch_ExactTextRuleWithMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/passed/"
            };

            var rule = new UrlRule("/passed/");

            Assert.IsTrue(rule.IsMatch(request));

            // test for case sensitivity
            request.RawUrl = "/PASSED/";
            Assert.IsTrue(rule.IsMatch(request));
        }
Ejemplo n.º 10
0
        public void InitializeFromSettings_WithValidSettings_InitializesCorrectly(string httpMethod, string expectedHttpMethod)
        {
            var settings = new[]
            {
                new RuleSetting {
                    Name = "url.value", Value = httpMethod
                }
            };

            var rule = new UrlRule();

            rule.InitializeFromSettings(settings);

            Assert.IsTrue(rule.IsInitialized);
            Assert.AreEqual(expectedHttpMethod, rule.UrlTextMatch);
        }
Ejemplo n.º 11
0
        public void IsMatch_RegexRuleInversedWithMatchingStringAgainst_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/passed/"
            };

            var rule = new UrlRule("not:regex:as*ed");

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

            /* test for case sensitivity */

            request = new MockHttpRequest
            {
                RawUrl = "/PASSED/"
            };
            Assert.IsFalse(rule.IsMatch(request));
        }
Ejemplo n.º 12
0
        public void IsMatch_RegexRuleWithMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/passed/"
            };

            var rule = new UrlRule("regex:as*ed");

            Assert.IsTrue(rule.IsMatch(request));

            /* test for case sensitivity */

            request = new MockHttpRequest
            {
                RawUrl = "/PASSED/"
            };

            Assert.IsTrue(rule.IsMatch(request));
        }
Ejemplo n.º 13
0
        public void IsMatch_RegexRuleInversedWithNonMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/failed/"
            };

            var rule = new UrlRule("not:regex:as*ed");

            Assert.IsTrue(rule.IsMatch(request));

            /* test for case sensitivity */

            request = new MockHttpRequest
            {
                RawUrl = "/FAILED/"
            };

            Assert.IsTrue(rule.IsMatch(request));
        }
Ejemplo n.º 14
0
        public void IsMatch_ExactTextRuleWithMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/passed/"
            };

            var rule = new UrlRule("/passed/");
            Assert.IsTrue(rule.IsMatch(request));

            // test for case sensitivity
            request.RawUrl = "/PASSED/";
            Assert.IsTrue(rule.IsMatch(request));
        }
Ejemplo n.º 15
0
        public void IsMatch_RegexRuleInversedWithMatchingStringAgainst_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/passed/"
            };

            var rule = new UrlRule("not:regex:as*ed");
            Assert.IsFalse(rule.IsMatch(request));

            // test for case sensitivity

            request = new MockHttpRequest
            {
                RawUrl = "/PASSED/"
            };
            Assert.IsFalse(rule.IsMatch(request));
        }
Ejemplo n.º 16
0
        public void IsMatch_RegexRuleInversedWithNonMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/failed/"
            };

            var rule = new UrlRule("not:regex:as*ed");
            Assert.IsTrue(rule.IsMatch(request));

            // test for case sensitivity

            request = new MockHttpRequest
            {
                RawUrl = "/FAILED/"
            };

            Assert.IsTrue(rule.IsMatch(request));
        }
Ejemplo n.º 17
0
        public void IsMatch_RegexRuleWithNonMatchingString_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                RawUrl = "/failed/"
            };

            var rule = new UrlRule("regex:as*ed");
            Assert.IsFalse(rule.IsMatch(request));
        }
Ejemplo n.º 18
0
 public void IsMatch_WithNullRequest_ReturnsFalse()
 {
     var rule = new UrlRule("/Something");
     Assert.IsFalse(rule.IsMatch(null));
 }
Ejemplo n.º 19
0
 public void GetRuleSettings_WhenCalled_ReturnsList()
 {
     var rule = new UrlRule("a");
     var list = new List<RuleSetting>(rule.GetRuleSettings());
     Assert.AreEqual(1, list.Count);
 }
Ejemplo n.º 20
0
 public void Constructor_Default_NotInitialized()
 {
     var rule = new UrlRule();
     Assert.IsFalse(rule.IsInitialized);
 }
Ejemplo n.º 21
0
        public void IsMatch_WithNullRequest_ReturnsFalse()
        {
            var rule = new UrlRule("/Something");

            Assert.IsFalse(rule.IsMatch(null));
        }
Ejemplo n.º 22
0
        public void Constructor_Default_NotInitialized()
        {
            var rule = new UrlRule();

            Assert.IsFalse(rule.IsInitialized);
        }
Ejemplo n.º 23
0
        public void IsMatch_NullValue_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                RawUrl = null
            };

            var rule = new UrlRule(null);
            Assert.IsFalse(rule.IsMatch(request));

            rule = new UrlRule("/test");
            Assert.IsFalse(rule.IsMatch(request));
        }