A class that provides a friendly interface for managing the settings of a T:Stumps.IStumpRule object.
        public void FindByteArray_WithInvalidSetting_ReturnsDefault()
        {
            var helper   = new RuleSettingsHelper();
            var expected = new byte[] { 1, 2, 3 };

            CollectionAssert.AreEqual(expected, helper.FindByteArray("good", expected));
        }
 public void AddForInteger_WithNullSettingName_ThrowsException()
 {
     var helper = new RuleSettingsHelper();
     Assert.That(
         () => helper.Add(null, 15),
         Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("settingName"));
 }
        public void FindInteger_WithInvalidSetting_ReturnsDefault()
        {
            var helper   = new RuleSettingsHelper();
            var expected = 15;

            Assert.AreEqual(expected, helper.FindInteger("good", expected));
        }
        public void FindBooelan_WithInvalidSetting_ReturnsDefault()
        {
            var helper = new RuleSettingsHelper();

            Assert.IsFalse(helper.FindBoolean("good", false));
            Assert.IsTrue(helper.FindBoolean("good", true));
        }
        public void FindString_WithInvalidSetting_ReturnsDefault()
        {
            var helper   = new RuleSettingsHelper();
            var expected = "goodbye";

            Assert.AreEqual(expected, helper.FindString("good", expected));
        }
        public void AddForByteArray_WithValidValue_UpdatesDictionary()
        {
            var helper = new RuleSettingsHelper();

            helper.Add("good", new byte[] { 1, 2, 3 });
            Assert.AreEqual(1, helper.Count);
        }
        public void AddForBoolean_WithValidValue_UpdatesDictionary()
        {
            var helper = new RuleSettingsHelper();

            helper.Add("good", true);
            Assert.AreEqual(1, helper.Count);
        }
 public void AddForByteArray_WithNullValue_ThrowsException()
 {
     var helper = new RuleSettingsHelper();
     byte[] bytes = null;
     Assert.That(
         () => helper.Add("good", bytes),
         Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("value"));
 }
        public void AddForInteger_WithNullSettingName_ThrowsException()
        {
            var helper = new RuleSettingsHelper();

            Assert.That(
                () => helper.Add(null, 15),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("settingName"));
        }
        public void AddForString_WithNullValue_ThrowsException()
        {
            var    helper = new RuleSettingsHelper();
            string s      = null;

            Assert.That(
                () => helper.Add("good", s),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("value"));
        }
        public void AddForByteArray_WithEmptyValue_ThrowsException()
        {
            var helper = new RuleSettingsHelper();

            byte[] bytes = new byte[0];
            Assert.That(
                () => helper.Add("good", bytes),
                Throws.Exception.TypeOf <ArgumentOutOfRangeException>().With.Property("ParamName").EqualTo("value"));
        }
        public void FindBooelan_WithValidSetting_ReturnsValue()
        {
            var helper       = new RuleSettingsHelper();
            var expected     = true;
            var defaultValue = false;

            helper.Add("good", expected);
            Assert.AreEqual(expected, helper.FindBoolean("good", defaultValue));
        }
        public void FindInteger_WithValidSetting_ReturnsValue()
        {
            var helper       = new RuleSettingsHelper();
            var expected     = 15;
            var defaultValue = 20;

            helper.Add("good", expected);
            Assert.AreEqual(expected, helper.FindInteger("good", defaultValue));
        }
        public void FindString_WithValidSetting_ReturnsValue()
        {
            var helper       = new RuleSettingsHelper();
            var expected     = "hello";
            var defaultValue = "goodbye";

            helper.Add("good", expected);
            Assert.AreEqual(expected, helper.FindString("good", defaultValue));
        }
        public void FindByteArray_WithValidSetting_ReturnsValue()
        {
            var helper       = new RuleSettingsHelper();
            var expected     = new byte[] { 1, 2, 3 };
            var defaultValue = new byte[] { 4, 5, 6 };

            helper.Add("good", expected);
            CollectionAssert.AreEqual(expected, helper.FindByteArray("good", defaultValue));
        }
        public void AddForExistingSetting_UpdatesSetting_UpdatesDictionary()
        {
            var expected = "override";
            var helper   = new RuleSettingsHelper();

            helper.Add("good", true);
            helper.Add("good", expected);
            Assert.AreEqual(1, helper.Count);
            Assert.AreEqual(expected, helper.FindString("good", "good"));
        }
示例#17
0
        public void AddForExistingSetting_UpdatesSetting_UpdatesDictionary()
        {
            var expected = "override";
            var helper = new RuleSettingsHelper();

            helper.Add("good", true);
            helper.Add("good", expected);
            Assert.AreEqual(1, helper.Count);
            Assert.AreEqual(expected, helper.FindString("good", "good"));
        }
        public void Constructor_WithSetting_Initializes(string settingName, string settingValue, int expectedCount)
        {
            var setting = new RuleSetting
            {
                Name  = settingName,
                Value = settingValue
            };

            var helper = new RuleSettingsHelper(
                new RuleSetting[]
            {
                setting
            });

            Assert.AreEqual(expectedCount, helper.Count);
        }
示例#19
0
 public void FindInteger_WithValidSetting_ReturnsValue()
 {
     var helper = new RuleSettingsHelper();
     var expected = 15;
     var defaultValue = 20;
     helper.Add("good", expected);
     Assert.AreEqual(expected, helper.FindInteger("good", defaultValue));
 }
示例#20
0
 public void FindByteArray_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     var expected = new byte[] { 1, 2, 3 };
     CollectionAssert.AreEqual(expected, helper.FindByteArray("good", expected));
 }
示例#21
0
 public void FindByteArray_WithValidSetting_ReturnsValue()
 {
     var helper = new RuleSettingsHelper();
     var expected = new byte[] { 1, 2, 3 };
     var defaultValue = new byte[] { 4, 5, 6 };
     helper.Add("good", expected);
     CollectionAssert.AreEqual(expected, helper.FindByteArray("good", defaultValue));
 }
示例#22
0
 public void AddForByteArray_WithValidValue_UpdatesDictionary()
 {
     var helper = new RuleSettingsHelper();
     helper.Add("good", new byte[] { 1, 2, 3 });
     Assert.AreEqual(1, helper.Count);
 }
示例#23
0
 public void FindBooelan_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     Assert.IsFalse(helper.FindBoolean("good", false));
     Assert.IsTrue(helper.FindBoolean("good", true));
 }
示例#24
0
 public void FindBooelan_WithValidSetting_ReturnsValue()
 {
     var helper = new RuleSettingsHelper();
     var expected = true;
     var defaultValue = false;
     helper.Add("good", expected);
     Assert.AreEqual(expected, helper.FindBoolean("good", defaultValue));
 }
示例#25
0
        public void Constructor_WithSetting_Initializes(string settingName, string settingValue, int expectedCount)
        {
            var setting = new RuleSetting
            {
                Name = settingName,
                Value = settingValue
            };

            var helper = new RuleSettingsHelper(
                new RuleSetting[]
                {
                    setting
                });

            Assert.AreEqual(expectedCount, helper.Count);
        }
示例#26
0
 public void AddForStringr_WithValidValue_UpdatesDictionary()
 {
     var helper = new RuleSettingsHelper();
     helper.Add("good", "good");
     Assert.AreEqual(1, helper.Count);
 }
示例#27
0
 public void FindString_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     var expected = "goodbye";
     Assert.AreEqual(expected, helper.FindString("good", expected));
 }
        public void Constructor_Default_InitializesEmptyDictionary()
        {
            var helper = new RuleSettingsHelper();

            Assert.AreEqual(0, helper.Count);
        }
示例#29
0
 public void FindInteger_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     var expected = 15;
     Assert.AreEqual(expected, helper.FindInteger("good", expected));
 }
示例#30
0
 public void Constructor_Default_InitializesEmptyDictionary()
 {
     var helper = new RuleSettingsHelper();
     Assert.AreEqual(0, helper.Count);
 }
示例#31
0
 public void FindString_WithValidSetting_ReturnsValue()
 {
     var helper = new RuleSettingsHelper();
     var expected = "hello";
     var defaultValue = "goodbye";
     helper.Add("good", expected);
     Assert.AreEqual(expected, helper.FindString("good", defaultValue));
 }