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

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

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

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

            var rule = new HttpMethodRule("not:POST");
            Assert.IsFalse(rule.IsMatch(request));
        }
Esempio n. 5
0
        public void IsMatch_ExactTextRuleWithNonMatchingString_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "POST"
            };

            var rule = new HttpMethodRule("GET");

            Assert.IsFalse(rule.IsMatch(request));
        }
Esempio n. 6
0
        public void IsMatch_RegexRuleWithNonMatchingString_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "POST"
            };

            var rule = new HttpMethodRule("regex:(get|put)");

            Assert.IsFalse(rule.IsMatch(request));
        }
Esempio n. 7
0
        public void IsMatch_ExactTextRuleInversedWithNonMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "GET"
            };

            var rule = new HttpMethodRule("not:POST");

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

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

            Assert.IsTrue(rule.IsInitialized);
            Assert.AreEqual(expectedHttpMethod, rule.HttpMethodTextMatch);
        }
Esempio n. 9
0
        public void IsMatch_NullValue_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = null
            };

            var rule = new HttpMethodRule(null);

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

            rule = new HttpMethodRule("GET");
            Assert.IsFalse(rule.IsMatch(request));
        }
Esempio n. 10
0
        public void IsMatch_ExactTextRuleWithMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "GET"
            };

            var rule = new HttpMethodRule("GET");

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

            // test for case sensitivity
            request.HttpMethod = "get";
            Assert.IsTrue(rule.IsMatch(request));
        }
Esempio n. 11
0
        public void InitializeFromSettings_WithValidSettings_InitializesCorrectly(string httpMethod, string expectedHttpMethod)
        {
            var settings = new[]
            {
                new RuleSetting {
                    Name = "httpmethod.value", Value = httpMethod
                }
            };

            var rule = new HttpMethodRule();

            rule.InitializeFromSettings(settings);

            Assert.IsTrue(rule.IsInitialized);
            Assert.AreEqual(expectedHttpMethod, rule.HttpMethodTextMatch);
        }
Esempio n. 12
0
        public void IsMatch_RegexRuleInversedWithMatchingString_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "GET"
            };

            var rule = new HttpMethodRule("not:regex:(get|put)");

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

            /* test for case sensitivity */

            request = new MockHttpRequest
            {
                HttpMethod = "get"
            };
            Assert.IsFalse(rule.IsMatch(request));
        }
Esempio n. 13
0
        public void IsMatch_ExactTextRuleWithMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "GET"
            };

            var rule = new HttpMethodRule("GET");
            Assert.IsTrue(rule.IsMatch(request));

            // test for case sensitivity
            request.HttpMethod = "get";
            Assert.IsTrue(rule.IsMatch(request));
        }
Esempio n. 14
0
        public void IsMatch_RegexRuleInversedWithNonMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "POST"
            };

            var rule = new HttpMethodRule("not:regex:(get|put)");
            Assert.IsTrue(rule.IsMatch(request));

            // test for case sensitivity

            request = new MockHttpRequest
            {
                HttpMethod = "post"
            };

            Assert.IsTrue(rule.IsMatch(request));
        }
Esempio n. 15
0
        public void IsMatch_RegexRuleWithMatchingString_ReturnsTrue()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "GET"
            };

            var rule = new HttpMethodRule("regex:(get|put)");
            Assert.IsTrue(rule.IsMatch(request));

            // test for case sensitivity

            request = new MockHttpRequest
            {
                HttpMethod = "get"
            };

            Assert.IsTrue(rule.IsMatch(request));
        }
Esempio n. 16
0
        public void IsMatch_RegexRuleWithNonMatchingString_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "POST"
            };

            var rule = new HttpMethodRule("regex:(get|put)");
            Assert.IsFalse(rule.IsMatch(request));
        }
Esempio n. 17
0
 public void IsMatch_WithNullRequest_ReturnsFalse()
 {
     var rule = new HttpMethodRule("POST");
     Assert.IsFalse(rule.IsMatch(null));
 }
Esempio n. 18
0
 public void GetRuleSettings_WhenCalled_ReturnsList()
 {
     var rule = new HttpMethodRule("a");
     var list = new List<RuleSetting>(rule.GetRuleSettings());
     Assert.AreEqual(1, list.Count);
 }
Esempio n. 19
0
        public void IsMatch_WithNullRequest_ReturnsFalse()
        {
            var rule = new HttpMethodRule("POST");

            Assert.IsFalse(rule.IsMatch(null));
        }
Esempio n. 20
0
 public void Constructor_Default_NotInitialized()
 {
     var rule = new HttpMethodRule();
     Assert.IsFalse(rule.IsInitialized);
 }
Esempio n. 21
0
        public void Constructor_Default_NotInitialized()
        {
            var rule = new HttpMethodRule();

            Assert.IsFalse(rule.IsInitialized);
        }
Esempio n. 22
0
        public void IsMatch_NullValue_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = null
            };

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

            rule = new HttpMethodRule("GET");
            Assert.IsFalse(rule.IsMatch(request));
        }