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

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

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

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

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

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

            helper.Add("good", true);
            Assert.AreEqual(1, helper.Count);
        }
Ejemplo n.º 8
0
 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"));
 }
Ejemplo n.º 9
0
        public void AddForInteger_WithNullSettingName_ThrowsException()
        {
            var helper = new RuleSettingsHelper();

            Assert.That(
                () => helper.Add(null, 15),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("settingName"));
        }
Ejemplo n.º 10
0
        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"));
        }
Ejemplo n.º 11
0
        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"));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
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));
        }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
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));
        }
Ejemplo n.º 16
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"));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 22
0
 public void AddForByteArray_WithValidValue_UpdatesDictionary()
 {
     var helper = new RuleSettingsHelper();
     helper.Add("good", new byte[] { 1, 2, 3 });
     Assert.AreEqual(1, helper.Count);
 }
Ejemplo n.º 23
0
 public void FindBooelan_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     Assert.IsFalse(helper.FindBoolean("good", false));
     Assert.IsTrue(helper.FindBoolean("good", true));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 26
0
 public void AddForStringr_WithValidValue_UpdatesDictionary()
 {
     var helper = new RuleSettingsHelper();
     helper.Add("good", "good");
     Assert.AreEqual(1, helper.Count);
 }
Ejemplo n.º 27
0
 public void FindString_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     var expected = "goodbye";
     Assert.AreEqual(expected, helper.FindString("good", expected));
 }
Ejemplo n.º 28
0
        public void Constructor_Default_InitializesEmptyDictionary()
        {
            var helper = new RuleSettingsHelper();

            Assert.AreEqual(0, helper.Count);
        }
Ejemplo n.º 29
0
 public void FindInteger_WithInvalidSetting_ReturnsDefault()
 {
     var helper = new RuleSettingsHelper();
     var expected = 15;
     Assert.AreEqual(expected, helper.FindInteger("good", expected));
 }
Ejemplo n.º 30
0
 public void Constructor_Default_InitializesEmptyDictionary()
 {
     var helper = new RuleSettingsHelper();
     Assert.AreEqual(0, helper.Count);
 }
Ejemplo n.º 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));
 }