InitializeFromSettings() public method

Initializes a rule from an enumerable list of T:Stumps.RuleSetting objects.
public InitializeFromSettings ( IEnumerable settings ) : void
settings IEnumerable The enumerable list of objects.
return void
        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));
        }
Esempio n. 2
0
        public void InitializeFromSettings_WithNullSettings_ThrowsException()
        {
            var rule = new BodyContentRule();

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

            Assert.That(
                () => rule.InitializeFromSettings(null),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("settings"));
        }
Esempio n. 4
0
        public void InitializeFromSettings_WhenInitialized_ThrowsException()
        {
            var rule = new BodyContentRule(new string[] { "ABCD" });
            var settings = new[] { new RuleSetting { Name = "text.evaluation", Value = "passed" } };

            Assert.That(
                () => rule.InitializeFromSettings(settings),
                Throws.Exception.TypeOf<InvalidOperationException>());
        }
        public void InitializeFromSettings_WhenInitialized_ThrowsException()
        {
            var rule     = new BodyContentRule(new string[] { "ABCD" });
            var settings = new[] { new RuleSetting {
                                       Name = "text.evaluation", Value = "passed"
                                   } };

            Assert.That(
                () => rule.InitializeFromSettings(settings),
                Throws.Exception.TypeOf <InvalidOperationException>());
        }
Esempio n. 6
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));
        }