A class representing a Stump rule that evaluates the exact content of the body of an HTTP request.
상속: IStumpRule
예제 #1
0
        public void GetRuleSettings_WhenCalled_ReturnsList()
        {
            var rule = new BodyMatchRule(3, "010203");
            var list = new List <RuleSetting>(rule.GetRuleSettings());

            Assert.AreEqual(2, list.Count);
        }
예제 #2
0
        public void InitializeFromSettings_WithNullSettings_ThrowsException()
        {
            var rule = new BodyMatchRule();

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

            Assert.That(
                () => rule.InitializeFromSettings(null),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("settings"));
        }
예제 #4
0
        public void IsMatch_GivenBodyDifferentFromRuleButSameSize_ReturnsFalse()
        {
            var requestBody = GenerateByteArray(3, Environment.TickCount);

            var rule = new BodyMatchRule(3, "010203");

            var request = CreateRequest(requestBody);
            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #5
0
        public void IsMatch_GivenBodyIsSameAsRule_ReturnsTrue()
        {
            var requestBody = new byte[] { 1, 2, 3 };

            var rule = new BodyMatchRule(3, "5289DF737DF57326FCDD22597AFB1FAC");

            var request = CreateRequest(requestBody);

            Assert.IsTrue(rule.IsMatch(request));
        }
예제 #6
0
        public void IsMatch_GivenBodyDifferentFromRuleButSameSize_ReturnsFalse()
        {
            var requestBody = GenerateByteArray(3, Environment.TickCount);

            var rule = new BodyMatchRule(3, "010203");

            var request = CreateRequest(requestBody);

            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #7
0
        public void IsMatch_WithDifferentBodySizes_ReturnsFalse()
        {
            var requestBody = GenerateByteArray(10, Environment.TickCount);

            var rule = new BodyMatchRule(3, "010203");

            var request = CreateRequest(requestBody);

            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #8
0
        public void InitializeFromSettings_WithValidSettings_InitializesCorrectly()
        {
            var settings = new[]
            {
                new RuleSetting { Name = "body.length", Value = "3" },
                new RuleSetting { Name = "body.md5", Value = "010203" }
            };

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

            Assert.IsTrue(rule.IsInitialized);
            Assert.AreEqual(3, rule.BodyLength);
            Assert.AreEqual("010203", rule.Md5Hash);
        }
예제 #9
0
        public void InitializeFromSettings_WithValidSettings_InitializesCorrectly()
        {
            var settings = new[]
            {
                new RuleSetting {
                    Name = "body.length", Value = "3"
                },
                new RuleSetting {
                    Name = "body.md5", Value = "010203"
                }
            };

            var rule = new BodyMatchRule();

            rule.InitializeFromSettings(settings);

            Assert.IsTrue(rule.IsInitialized);
            Assert.AreEqual(3, rule.BodyLength);
            Assert.AreEqual("010203", rule.Md5Hash);
        }
예제 #10
0
        public void IsMatch_WithDifferentBodySizes_ReturnsFalse()
        {
            var requestBody = GenerateByteArray(10, Environment.TickCount);

            var rule = new BodyMatchRule(3, "010203");

            var request = CreateRequest(requestBody);
            Assert.IsFalse(rule.IsMatch(request));
        }
예제 #11
0
        public void IsMatch_GivenBodyIsSameAsRule_ReturnsTrue()
        {
            var requestBody = new byte[] { 1, 2, 3 };

            var rule = new BodyMatchRule(3, "5289DF737DF57326FCDD22597AFB1FAC");

            var request = CreateRequest(requestBody);
            Assert.IsTrue(rule.IsMatch(request));
        }
예제 #12
0
 public void GetRuleSettings_WhenCalled_ReturnsList()
 {
     var rule = new BodyMatchRule(3, "010203");
     var list = new List<RuleSetting>(rule.GetRuleSettings());
     Assert.AreEqual(2, list.Count);
 }
예제 #13
0
 public void Constructor_Default_NotInitialized()
 {
     var rule = new BodyMatchRule();
     Assert.IsFalse(rule.IsInitialized);
 }
예제 #14
0
 public void IsMatch_WithNullRequest_ReturnsFalse()
 {
     var rule = new BodyMatchRule(3, "010203");
     Assert.IsFalse(rule.IsMatch(null));
 }
예제 #15
0
        public void IsMatch_WithNullRequest_ReturnsFalse()
        {
            var rule = new BodyMatchRule(3, "010203");

            Assert.IsFalse(rule.IsMatch(null));
        }
예제 #16
0
        public void Constructor_Default_NotInitialized()
        {
            var rule = new BodyMatchRule();

            Assert.IsFalse(rule.IsInitialized);
        }