A class representing a Stump rule that evaluates the HTTP method of an HTTP request.
Inheritance: IStumpRule
Exemplo 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);
        }
Exemplo 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"));
        }
Exemplo 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"));
        }
Exemplo 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));
        }
Exemplo n.º 5
0
        public void IsMatch_ExactTextRuleWithNonMatchingString_ReturnsFalse()
        {
            var request = new MockHttpRequest
            {
                HttpMethod = "POST"
            };

            var rule = new HttpMethodRule("GET");

            Assert.IsFalse(rule.IsMatch(request));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo n.º 17
0
 public void IsMatch_WithNullRequest_ReturnsFalse()
 {
     var rule = new HttpMethodRule("POST");
     Assert.IsFalse(rule.IsMatch(null));
 }
Exemplo 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);
 }
Exemplo n.º 19
0
        public void IsMatch_WithNullRequest_ReturnsFalse()
        {
            var rule = new HttpMethodRule("POST");

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

            Assert.IsFalse(rule.IsInitialized);
        }
Exemplo 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));
        }